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
Post a Comment