Programming a Menu for our Mole Munch project

Recovering from the hectic last week where we had to code so much, especially the last days before our Alpha deadline, we now look towards the Beta deadline. Several things still need to be implemented: powerup, improved projectile (the object I was working on last week), graphics and some other things. This week I will be finishing the projectile completely and I’ll also be implementing graphics to our game. But this blog post will be about what I’ve been working on for the most part this week, our menu for the game. The menu is meant to be a way for the player to start or exit the game when they boot up the game. There’s also a button for instructions that displays a picture showing what buttons are used in the game, and what the objective is.

The menu contains 3 different buttons; Play, Instructions and Exit. By clicking on play with your mouse, the game will call for the function GetNextState(); which will get the player onto the next state, GameState. By clicking on exit, the game will stop running by returning the bool m_running in Engine.cpp to false. This will make the whole game stop, since that variable decides if the game is running or not. If instructions button is pressed, a sprite will be loaded displaying information that the player will need in order to play the game.

The menu is handled by the class MenuState, which shares some functions with PlayState. Functions that are shared are: Enter(), Exit(), Update(float delatime), Draw() and OnAction(). These functions are all inherited from the class AbstractState, which contains virtual functions that the different states can inherit. The different states are being handled together by the StateManager class, which has some useful functions that help manage the different states.

As of the time of this writing, the MenuState is almost finished, it just needs some final polishing. The different sprites aren’t completely finished either, but these will be added to the code as soon as they are done.

Below is how the buttons will look like, but the complete menuscreen is still being worked on so for now what is best shown is the buttons. An instruction button will also be added eventually.

The buttons will be able to be clicked using the mouse, but when the game starts, the mouse will be invisible since the game is played using keyboard. Showing the mouse in the PlayState won’t be any beneficial, but for the MenuState, it feels like the player should be able to click the different buttons instead of having to press the keyboard to access what the buttons are going to do.