Sign in to follow this  
TristanAnselT.Angeles

Making menu screen for games and levels

Recommended Posts

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!

Share this post


Link to post
Share on other sites
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();

Share this post


Link to post
Share on other sites
I suggest you skim through these articles on [url="http://lazyfoo.net/articles/article06/index.php"]State Machines[/url] and [url="http://lazyfoo.net/articles/article04/index.php"]Game Loops[/url].

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 ).

Share this post


Link to post
Share on other sites
[url="http://www.xnadevelopment.com/tutorials/thestateofthings/thestateofthings.shtml"]Link[/url]
If you read this you will be ok.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this