We Got Dungeons - Dev Log 3
Welcome back to our dev log for We Got Dungeons!
Today we are going to talk about the game object structures and how they interact with each other.
One of the problems we encountered immediately when we started the development of We Got Dungeons was how to create a game that has interesting, polymorphic interactions between all game objects. What polymorphism entails is basically having the ability to apply any interaction, like for example an attack, to any game object regardless of the object's type.
Actions and items that interface with one another can result in some unique tactical situations. However, this system is somewhat unheard of in the Sega Genesis. The main challenge stemmed from the fact that we are using C to write this game, which unfortunately does not have classes that make these types of problems a little easier to solve.
After some brainstorming and many failed prototypes, we settled on the following design. All interactions are functions that take two parameters, the source of the interaction and the target.
Game objects have their own separate structures, but all of them are wrapped in a generic gameObject structure by using a union of structures like so:
What this allows for is passing game object pointers to interaction functions without the need to worry about their type.
The interaction functions are completely modular blocks of code that get invoked through function pointers as needed. This is not only great for quickly adding interactions and testing them without the need to drastically change the code base, but also makes the debugging of the same much faster.
Another bonus is that any game object can have any interaction. So for example an item or a trap might have an interaction that an enemy usually has. This adds the possibility of complex environmental interactions that result in exciting and dynamic combat encounters as well as tense and dangerous dungeon delving and exploration! It adds a whole new level of tactics and strategy to this already deeply customizable RPG!
Pushing these retro systems beyond their limits is something we strive for in our games, and the object interaction system of We Got Dungeons is a great example of what new retro games have to offer.
Join us in part 4 of our series when we will discuss how we manage pathfinding and basic enemy AI.