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.
davideliasson 12:04 den 3 mars, 2015 Direktlänk |
Hey Olle! First of I think you explain very well what it is that you have been working on in a calm order of what they are and how they are going to work. You give an detailed explanation of what functions you are working with as well the variables needed and depending of how they change the outcome will be different. Also that you explain that briefly how the class itself inherent gives a clearer picture on how all corresponds with each other.
Nice quirk that in menu state the mouse is visible and once you enter game state it disappear, nicely done and i can see how that would be useful and be better for your game. I have however some questions after i have read you text and that is firstly how the instruction sprite will work if it will cover the screen that you will need to close before you can press play or simply be a smaller sprite where you can press play directly. And how you would close it if needed to. But apart from this it was a well written blog in my opinion and i understood what have been working on and how it would work.
//Feedback from David Eliasson, Group 10, 5SD033, GAME
GillaGilla