Making menu screen for games and levels

Started by
3 comments, last by TristanAnselT.Angeles 12 years, 8 months ago
Hi!

I'm having trouble with adding a menu screen for my game. How does one exactly program this into the game?
Do I make a new screen(for pygame) for the menu screen before going to the main game? Do I make a separate class
for the menu screen?Is it included in the main loop etc?

What about game levels?How are these usually programmed into games? Sorry for the noob question, almost all the tutorials I've found deal with games with one level and no menu screen(it starts with games directly). Any

Thanks!
Advertisement
The way this is usually done is by implementing a State System, in which the game has several states such as "GameplayState", "MainMenuState" and "IntroductionState". If you're in the Main Menu, and you press the "Play Game" button, you'd change the state to "GameplayState".

In the game loop, or manager, depending on your design, you'd simply call the update method of your current state:

currentState->update();


and when you change state you do something like this:


currentState = GameplayState::Instance();
I suggest you skim through these articles on State Machines and Game Loops.

I've also seen it done where the statemachine is a vector, and each time you need to go forward a state you 'push' it onto the vector( like from menu to game.. ) and when you want to go backward you pop it off(like from settings back to menu ).
Link
If you read this you will be ok.
Thanks for the links to the articles! I'm reading them now and they're exactly what I was looking for!:rolleyes:

This topic is closed to new replies.

Advertisement