highscore_menu = new Menu();
contrib_menu = new Menu();
contrib_subset_menu = new Menu();
+ worldmap_menu = new Menu();
main_menu->set_pos(screen->w/2, 335);
main_menu->additem(MN_GOTO, "Start Game",0,load_game_menu);
game_menu->additem(MN_HL,"",0,0);
game_menu->additem(MN_ACTION,"Quit Game",0,0);
+ worldmap_menu->additem(MN_LABEL,"Worldmap Menu",0,0);
+ worldmap_menu->additem(MN_HL,"",0,0);
+ worldmap_menu->additem(MN_ACTION,"Return To Game",0,0);
+ worldmap_menu->additem(MN_GOTO,"Options",0,options_menu);
+ worldmap_menu->additem(MN_HL,"",0,0);
+ worldmap_menu->additem(MN_ACTION,"Quit Game",0,0);
+
highscore_menu->additem(MN_TEXTFIELD,"Enter your name:",0,0);
}
void
WorldMap::get_input()
{
- SDL_Event event;
-
enter_level = false;
input_direction = NONE;
-
+
+ SDL_Event event;
while (SDL_PollEvent(&event))
{
- switch(event.type)
+ if(show_menu)
{
- case SDL_QUIT:
- quit = true;
- break;
-
- case SDL_KEYDOWN:
- switch(event.key.keysym.sym)
+ current_menu->event(event);
+ }
+ else
+ {
+ switch(event.type)
{
- case SDLK_ESCAPE:
+ case SDL_QUIT:
quit = true;
break;
- case SDLK_LCTRL:
- case SDLK_RETURN:
- enter_level = true;
- break;
- default:
- break;
- }
- break;
- case SDL_JOYAXISMOTION:
- switch(event.jaxis.axis)
- {
- case JOY_X:
- if (event.jaxis.value < -JOYSTICK_DEAD_ZONE)
- input_direction = WEST;
- else if (event.jaxis.value > JOYSTICK_DEAD_ZONE)
- input_direction = EAST;
+ case SDL_KEYDOWN:
+ switch(event.key.keysym.sym)
+ {
+ case SDLK_ESCAPE:
+ Menu::set_current(worldmap_menu);
+ show_menu = !show_menu;
+ break;
+ case SDLK_LCTRL:
+ case SDLK_RETURN:
+ enter_level = true;
+ break;
+ default:
+ break;
+ }
break;
- case JOY_Y:
- if (event.jaxis.value > JOYSTICK_DEAD_ZONE)
- input_direction = SOUTH;
- else if (event.jaxis.value < -JOYSTICK_DEAD_ZONE)
- input_direction = NORTH;
+
+ case SDL_JOYAXISMOTION:
+ switch(event.jaxis.axis)
+ {
+ case JOY_X:
+ if (event.jaxis.value < -JOYSTICK_DEAD_ZONE)
+ input_direction = WEST;
+ else if (event.jaxis.value > JOYSTICK_DEAD_ZONE)
+ input_direction = EAST;
+ break;
+ case JOY_Y:
+ if (event.jaxis.value > JOYSTICK_DEAD_ZONE)
+ input_direction = SOUTH;
+ else if (event.jaxis.value < -JOYSTICK_DEAD_ZONE)
+ input_direction = NORTH;
+ break;
+ }
break;
- }
- break;
- case SDL_JOYBUTTONDOWN:
- if (event.jbutton.button == JOY_B)
- enter_level = true;
- break;
+ case SDL_JOYBUTTONDOWN:
+ if (event.jbutton.button == JOY_B)
+ enter_level = true;
+ break;
- default:
- break;
+ default:
+ break;
+ }
}
}
- Uint8 *keystate = SDL_GetKeyState(NULL);
+ if (!show_menu)
+ {
+ Uint8 *keystate = SDL_GetKeyState(NULL);
- if (keystate[SDLK_LEFT])
- input_direction = WEST;
- else if (keystate[SDLK_RIGHT])
- input_direction = EAST;
- else if (keystate[SDLK_UP])
- input_direction = NORTH;
- else if (keystate[SDLK_DOWN])
- input_direction = SOUTH;
+ if (keystate[SDLK_LEFT])
+ input_direction = WEST;
+ else if (keystate[SDLK_RIGHT])
+ input_direction = EAST;
+ else if (keystate[SDLK_UP])
+ input_direction = NORTH;
+ else if (keystate[SDLK_DOWN])
+ input_direction = SOUTH;
+ }
}
Point
tux->set_direction(input_direction);
tux->update(0.33f);
}
+
+ if(show_menu)
+ {
+ if(current_menu == worldmap_menu)
+ {
+ switch (worldmap_menu->check())
+ {
+ case 2: // Return to game
+ menu_reset();
+ break;
+ case 5: // Quit Worldmap
+ quit = true;
+ break;
+ }
+ }
+ }
}
Tile*
}
tux->draw();
- flipscreen();
}
void
draw();
get_input();
update();
+
+ menu_process_current();
+ flipscreen();
+
SDL_Delay(20);
}