- Upgraded ambient sound source to rounded rectangule dimension
[supertux.git] / src / game_session.cpp
index b4d44ad..86b38e3 100644 (file)
@@ -405,7 +405,7 @@ GameSession::check_end_conditions()
 }
 
 void
-GameSession::action(float elapsed_time)
+GameSession::update(float elapsed_time)
 {
   // handle controller
   if(main_controller->pressed(Controller::PAUSE_MENU))
@@ -414,7 +414,7 @@ GameSession::action(float elapsed_time)
   // advance timers
   if(!currentsector->player->growing_timer.started()) {
     // Update Tux and the World
-    currentsector->action(elapsed_time);
+    currentsector->update(elapsed_time);
   }
 
   // respawning in new sector?
@@ -485,7 +485,7 @@ GameSession::process_menu()
 {
   Menu* menu = Menu::current();
   if(menu) {
-    menu->action();
+    menu->update();
 
     if(menu == game_menu) {
       switch (game_menu->check()) {
@@ -533,14 +533,19 @@ GameSession::run()
     if(!game_pause)
       global_time += elapsed_time;
 
-    skipdraw = false;
-
     // regulate fps
     ticks = SDL_GetTicks();
     if(ticks > fps_nextframe_ticks) {
-      // don't draw all frames when we're getting too slow
-      skipdraw = true;
+      if(skipdraw == true) {
+        // already skipped last frame? we have to slow down the game then...
+        skipdraw = false;
+        fps_nextframe_ticks -= (Uint32) (1000.0 / LOGICAL_FPS);
+      } else {
+        // don't draw all frames when we're getting too slow
+        skipdraw = true;
+      }
     } else {
+      skipdraw = false;
       while(fps_nextframe_ticks > ticks) {
         /* just wait */
         // If we really have to wait long, then do an imprecise SDL_Delay()
@@ -576,9 +581,9 @@ GameSession::run()
       // Update the world
       check_end_conditions();
       if (end_sequence == ENDSEQUENCE_RUNNING)
-        action(elapsed_time/2);
+        update(elapsed_time/2);
       else if(end_sequence == NO_ENDSEQUENCE)
-        action(elapsed_time);
+        update(elapsed_time);
     }
     else
     {
@@ -631,6 +636,12 @@ GameSession::run()
 }
 
 void
+GameSession::finish()
+{
+  exit_status = ES_LEVEL_FINISHED;
+}
+
+void
 GameSession::respawn(const std::string& sector, const std::string& spawnpoint)
 {
   newsector = sector;