Separating the Game from the Engine


For the first sprint of this month, the plan was to prepare for the work coming up in the next couple of weeks with yet another Refactor session. The focus for this month would be on fleshing out ARPG gameplay features like a Loot System and Scaling Abilities so cleaning up the code so far to better separate the features specific to this game from more general features seemed like a good foundational task to start with.

The biggest challenge among these was the ECS implementation used in the Engine. The initial implementation used numbers arbitrarily assigned in code to refer to specific components and was cumbersome to use when creating a bunch of entities to populate a level. Additionally all the new features to be implemented would be adding more layers on top of the existing systems and components so this definitely seemed like the right time to make some changes to this part of the code.

To make the system generic enough to support the new features and not rely on arbitrary values hidden somewhere in a code file, a solution was chosen to lean heavier towards the Template Metaprogramming features of C++. This way, a game system could be specified by using the components it refers to or modifies as type parameters, making it a little easier for someone to read the code and also decreasing the amount of lines needed to create a new Entity with a specific set of components. This turned out to be a more difficult task that it was estimated to be, but in the end, we now have two separate projects for the Engine and Game code, making it a little easier to debug specific issues and quicker to go through.

In the end, all this extra effort lead to another behind-the-scenes change that made little difference in the final product. Hopefully, this'll be the last change of this kind with many of the tasks that remain being either Gameplay or Rendering features that reflect better in the final application.