Skip to main content

Data First Project

Last post I talked about a project I started using the approach of designing the data first.  It is my current pet project and one that I will keep exploring and playing with because it is so much fun.  So here are some snippets of code the show the structure of my data and some of its values.


One thing you might have noticed is that I am using the JSON data structure.  JSON is a great format and pretty much every language already has a JSON parsing library so it really let me focus on the design of the data and how each piece would reference/connect to other bits of data.  Just like code you spend a good chunk of time very early on iterating your data design.  My first attempt I found that I was nesting things way more then I really needed.  Since there was no code at this point it was super easy to just move things to new sections and make large sweeping changes until everything started to make logical sense for what I wish to accomplish.  As the data structure started to grow I wrote a few small scripts to quickly fill in the data such as an image parser that reads all the images in a folder and adds them to the image resources tab and then looks for images named in sequence and turns those into animations.  At this point I wanted to start to put some code together for reading the data which became the main engine.


The cool thing about the above video is that the code and the data are completely separated.  The way I thought about it is that I wanted to create a format for my game data that did not matter what code or engine ran it.  If I wanted to write my game in python or c++ I could without having to change my data I would just need to re-write my parsing code essentially.  The huge win in that regard is that the engine code is super small and far easier to maintain and grow then everything I have done before.  Another huge win is that I spend more time designing logic then code and when I go to write code I already have data to process so I can test my new code with actual data right away.


Comments

Popular posts from this blog

Level Buddy | Blender Addon

An old-school CSG inspired level editor add-on for Blender 3D. The add-on is still very much a work in progress but fairly solid for blocking spaces super quickly.  Just because graphic fidelity has gotten insanely good and hyper detailed doesn't mean we shouldn't look back how older games were put together, at least that is my opinion.  One thing I always come back to is how quickly the tools in the first 2 versions of Unreal Ed 2 and Doom level editors allowed anyone to block out a level, iterate on feedback or try an idea out.  So I just took some time to put together a similar pipeline right in my 3d package of choice.  I wanted to keep it simple and quick to try out level design ideas.  You can use it for simple white boxing of your level, break it up into multiple static meshes and import them into your game engine of choice or  you can use that as your starting point to start more detailed modeling ....

Random Level Generation

The level generation system in This Is Dungeon  uses a few different ideas to produce the final levels but I'm just going to go over the first right now.  Levels are generated using the Dungeon-Building Algorithm by Mike Anderson .  This algorithm is very simple to implement and gives really good results.  The levels generate very quickly and the player is guaranteed to be able to reach every room of the level. random dungeon no choke point. After playing around with the generated levels in game I started wanting to be able to break the map up into multiple sections.  Since the features are built one at a time from a previously built room I realized I could just tell the generator how many sections I wanted to break the map up into and divide that by the number of rooms it was trying to generate.  The result being the number of rooms that should go into each section.  With that info you just keep track of the rooms already built and when tha...

Rocky Terrain | Blender Internal Rendering

I saw a really awesome render of some rocks the other day and was inspired to see if I could recreate a version of my own of some rocky terrain so I made this little scene.  The scene was modled, rendered and composited in Blender 3D .  It is a very simple scene and made just for fun in a couple of hours.  The rocks are all subsurface cube objects that I run a noise displacement map on using the world coordinates.  This allowed me to just make instances of the cube and drag them around the scene to get different rock shapes.  Some of the rocks needed to be scaled to get some more size variation but that is pretty much the only thing that is different about them other then their positions.  It was actually really fun to just move the cube around the scene and watch these random rock shapes form.  After the layout was done I added in some particle grass to break the ground up.  Not enough time was spent on the grass so it looks pretty bad ...