Archived

This topic is now archived and is closed to further replies.

6Gold

Making a start screen and then switching to a new screen

Recommended Posts

6Gold    122
How do I make a start screen, then press a button and have a different screen? I know this is probably simple, but I think I''m thinking to complex (not smart, I mean difficult) If anyone replies thanks... 6 Gold Work hard today so tomorrow will be easy.

Share this post


Link to post
Share on other sites
Mike    141
create an enumerated type such as:

enum GAME_STATE { MAIN_MENU, LOAD_LEVEL, RUN_LEVEL, UNLOAD_LEVEL }


then in your main game loop switch between states:


while( game_is_running )
{
switch( game_state )
{
case MAIN_MENU:
DrawStartScreen();
if( enter_key_pressed ) game_state = LOAD_LEVEL;
break;

case LOAD_LEVEL:
LoadLevelData();
game_state = RUN_LEVEL;
break;
.
.
.
}


The above code is just psuedo code. It won''t work if you just copy and paste, but hopefully you get the idea.

Useless Code

Share this post


Link to post
Share on other sites
bobatefrei    122
Just use a code like this:



int introKey(char k, int x, int y)
{
if(k == ''q'')
{
glutKey(gameKey);
glutDisplay(gameDisplay);
glutDisplay(gameIdle);
...
}

}

void main()
{
glutKey(introKey);
glutDisplay(introDisplay);
glutIdle(introIdle);
...
glutMainLoop();
}

Share this post


Link to post
Share on other sites