January 13, 2016 by namespacestudio
So, my thought on game engines is that ideally, they will be easily extensible. What that means is that each script must be compartmentalized. The goal of my engine design was to allow the addition and subtraction of these components on the fly, so that I would only have to program a behavior once, and then I could add it to as many game objects as I needed. To do this, I gave each game object an internal dictionary of components, where the key was the class of component, and the value was the actual component of that type. then, I made a generic method to create an instance of a component object, and link the component object to the game object. This way, what appears to be a single game object is actually a collection of objects, with a game object’s duties delegated amongst them.
It took a while to get this model working, so before I completed this structure, I managed to do other things like create a rudimentary physics simulation, and implement SAT collision. (Both of which took me quite a while). However, once I had made the Game Object / Component structure, I had to break previously functional code apart in order to get the behavior I wanted in a component format. Since then, I’ve been using game components to add functionality like Overworld movement, level behaviors, platformer style movement, and the first implementation of a combat system.
By far the most complex area of this game is the combat system, which must be expertly tuned. Ignoring my instincts to try and tune it as I go has been difficult, but enlightening. I am expecting to have a robust combat system in the next couple of weeks. After that, it will be time to turn my attention to the asset pipeline. I have the game working with a tile map editor for overworld maps, but I still need at least two more editors to generate the json used for levels and gameObject loading. Writing them by hand has been problematic, and I would very much like to have a small application to generate them for me, as I’m sure everyone else at namespace would appreciate having access to them as well.