Portfolio


  • Home
  • DirectX Raytracing
  • Advanced Graphics
  • Roboflux
  • Boat Simulation

Unicorn game



The Project



I created this project for a module in my first year at university. I created an engine using the graphical API OpenGL. I then created this simple game in the engine to demonstrate its capabilities. This greatly helped further my understanding of games engines as I have more of an idea of how they function on a low level.



Classes



The first thing I did was I created a base class for an item to appear in the scene. This class included things like a pointer to a mesh struct, pointer to a texture, position, rotation etc. From here I created more specialised classes like the unicorn class. I decided to use pointers for the texture and mesh variables as this way I could load the mesh and the texture once at the start of the game. Then whenever I created a new unicorn I could just reference the same mesh and texture.



Loading and storing



The next thing I did was create an object loader and texture loader. These loaders provided necessary functionality in order to create complex objects and correctly represent them in my scene. After this I then set about setting up a way to store the high scores from the game. I did this by writing all the high scores to a file. Once a user ends their run the high scores are loaded from the file into an array and parsed through to see if they have a new high score. If they don't nothing happens. If they do all the values below that score are shifted down one and the last is overwritten. These values are then written back to the file.



Data structures and hitboxes



I also implemented various data structures like scene graphs and linked lists. The scene graphs allowed me to create a hierarchical structure which in turn allowed me to create more complex objects as multiple meshes could be easily used to create a character. This structure was used to create the solar system in the sky. The linked lists were useful as they are easy to manipulate and resize allowing me to very easily store all the objects.


The final addition I made were the hitboxes. I looked into a lot of different hitboxes such as axis aligned bounding boxes and oriented bounding boxes. I decided to implement axis aligned for simplicity and because the game I was creating was just for demonstration. I also read about hierarchical trees being used in order to carry out very detailed collision detection while still keeping computational cost low.