- Menu::set_current(main_menu);
- while (!done)
- {
- // Calculate the movement-factor
- double frame_ratio = ((double)(update_time-last_update_time))/((double)FRAME_RATE);
- if(frame_ratio > 1.5) /* Quick hack to correct the unprecise CPU clocks a little bit. */
- frame_ratio = 1.5 + (frame_ratio - 1.5) * 0.85;
- /* Lower the frame_ratio that Tux doesn't jump to hectically throught the demo. */
- frame_ratio /= 2;
-
- /* Handle events: */
-
- while (SDL_PollEvent(&event))
- {
- if (event.type == SDL_QUIT)
- {
- done = true;
- }
- else if (event.type == SDL_KEYDOWN)
- {
- /* Keypress... */
- key = event.key.keysym.sym;
-
- if (Menu::current())
- {
- Menu::current()->event(event);
- }
-
- if (!Menu::current())
- {
- /* Escape: Quit: */
- done = true;
- }
- }
- }
-
- /* Draw the background: */
- draw_background();
- draw_demo(&session, frame_ratio);
-
- if (Menu::current() == main_menu)
- logo->draw( 160, 30);
-
- white_small_text->draw(" SuperTux " VERSION "\n"
- "Copyright (c) 2003 SuperTux Devel Team\n"
- "This game comes with ABSOLUTELY NO WARRANTY. This is free software, and you\n"
- "are welcome to redistribute it under certain conditions; see the file COPYING\n"
- "for details.\n",
- 0, 420, 0);
-
- /* Don't draw menu, if quit is true */
- if(!done)
- {
- Menu::current()->action();
- Menu::current()->draw();
- }
-
- if(Menu::current() == main_menu)
- {
- switch (main_menu->check())
- {
- case 0:
- // Start Game, ie. goto the slots menu
- update_load_save_game_menu(load_game_menu);
- break;
- case 1:
- // Contrib Menu
- update_contrib_menu();
- break;
- case 3:
- done = true;
- done = leveleditor(1);
- Menu::set_current(main_menu);
- break;
- case 4:
- display_credits();
- break;
- case 5:
- done = true;
- break;
- }
- }
- else if(Menu::current() == options_menu)
- {
- process_options_menu();
- }
- else if(Menu::current() == load_game_menu)
- {
- if (process_load_game_menu())
- {
- // FIXME: shouldn't be needed if GameSession doesn't relay on global variables
- // reset tux
- scroll_x = 0;
- //titletux.level_begin();
- update_time = st_get_ticks();
- }
- }
- else if(Menu::current() == contrib_menu)
- {
- check_contrib_menu();
- }
- else if (Menu::current() == contrib_subset_menu)
- {
- check_contrib_subset_menu();
- }
-
- mouse_cursor->draw();
-
- flipscreen();
-
- /* Set the time of the last update and the time of the current update */
- last_update_time = update_time;
- update_time = st_get_ticks();
-
- /* Pause: */
- frame++;
- SDL_Delay(25);