This was my simplistic snake game project made for an assignment. The brief was to develop an educational snake game, where eating specific fruits gave you food. The goal was to eat two fruit numbers, which are then multiplied together, where you have to pickup the right answer fruit, otherwise your length goes down.
I ended up making 5 bonus gamemodes, which are Classic, Addition, Multiplication, Letters and Duel. I used SFML as the graphics Library for the project to keep things clean and simple to work with.Â
I created five different gamemodes that the player can play, each with a slightly different ruleset.
Each Gamemode had Unique Settings for difficulties, aswell as generic settings for fruit counts. I also had general game settings for skins and accessibility.
I created a pseudo-smart enemy snake, which was able to play against you and block your movements in its own gamemode.
I had to overcome lots of challenges in the development of this project. One of them was designing a Good UI system that I could use for multiple pages. I ended up having a main UI class, which can point to child UI classes. You can register a UIElement to each class, and subsribe to events such as when a button is pressed, all within a constructor.
I also had an issue where I wanted my buttons to have dynamic sizing, but with one texture. To be able to resize the buttons properly maintaining the border, I created a SplitImage class, which lets you specify a bounds and an edge for each image. The image is then drawn as a custom vertex shape which allows the main part of the texture to repeat, whereas the edge stays unwarped.
One small optimisation I made for my project, was the original background code. Originally I had a seperate draw call for the background tiles per segment, which was secretly tanking my performance until I found it. I ended up replacing the background with a custom generated vertex shape, creating squares for each tile, reducing it all to a draw call and gaining around 2,000 extra FPS.