An infinite runner game, built with a focus on code architecture. I created a component system that allows for reusable chunks of functionality to be added onto any object in the game.
Role: Programmer
Team: 1 Developer
Timeframe: 4 weeks
Engine: C++, Hornet Engine (Northumbria's SDL2 Engine)
I worked on this project as part of a university project, and took it beyond the specification. The project is built upon the Hornet engine, created by Northumbria University. I expanded the existing GameObject class to encompass the management of components. This allowed me to create code once that could be applied to any object. I used this for health and movement in this project, and has the possiblity of being used for collision, rendering etc. in the future.
My first task was to create a component base class. This would allow each component to be managed by its game object. This stored a GameObject pointer to the owning object. From this, I created several specific components for the game:
Animation State Component
Health Component
Movement Component
Shoot Component
User Interface Component
These provided modular code that could function on any game object.
To be able to add components to an object, I had to add tracking functionality to the base object class. This simply pushes the added component to a vector, and deletes it on destructor. Part of the requirements of the project was to exclusively use raw pointers to understand memory safe practices.
To be able to access the components of the current and other game objects, I created a template function to return the component of the requested tipe from the game object. This has the limitation that it will only return one component, and if the object has multiple of the same type of component it will only return the first of those. This wasn't an issue for the game I created, but if I was to create this in the future, I would create a second of these that would return all of the requested type of component.
Despite my main focus on the project being on the engine architecture, I also created a simple game loop. This took the form of an infinite runner. I used the movement component to create player and enemy movement. The player moves forward in the world, while the enemies move randomly forward and backward. I created an attack component which allowed a projectile to be created and shot. I implemented this on the player, but this could also be applied to enemies. The final gameplay feature is the shops. These allow the player to purchase more ammo and health, for the cost of coins. A simple UI was created, which was another component that displayed information to the player.