Making a start screen and then switching to a new screen

Started by
1 comment, last by 6Gold 22 years, 8 months ago
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.
Work hard today so tomorrow will be easy.
Advertisement
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
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();
}

This topic is closed to new replies.

Advertisement