Fixed levels on contribs menu.
[supertux.git] / src / gameloop.cpp
index 0ccf68d..a6c3a5f 100644 (file)
@@ -129,6 +129,11 @@ GameSession::restart_level()
   if(flip_level)
     level->do_vertical_flip();
 
+  global_stats.reset();
+  global_stats.set_total_points(COINS_COLLECTED_STAT, level->get_total_coins());
+  global_stats.set_total_points(BADGUYS_KILLED_STAT, level->get_total_badguys());
+  global_stats.set_total_points(TIME_NEEDED_STAT, level->time_left);
+
   currentsector = level->get_sector("main");
   if(!currentsector)
     Termination::abort("Level has no main sector.", "");
@@ -152,8 +157,6 @@ GameSession::restart_level()
         levelintro();
     }
 
-  global_stats.reset();
-
   time_left.init(true);
   start_timers();
   currentsector->play_music(LEVEL_MUSIC);
@@ -436,7 +439,8 @@ GameSession::process_events()
                           last_keys.clear();
                           }
                         if(compare_last(last_keys, "kill"))
-                          {    // kill Tux
+                          {    // kill Tux, but without losing a life
+                          player_status.lives++;
                           tux.kill(tux.KILL);
                           last_keys.clear();
                           }
@@ -548,14 +552,15 @@ GameSession::check_end_conditions()
   else if(!end_sequence && endtile && endtile->data == 0)
     {
       end_sequence = ENDSEQUENCE_RUNNING;
-      random_timer.start(200);  // start 1st firework
+      endsequence_timer.start(7000); // 5 seconds until we finish the map
       last_x_pos = -1;
       SoundManager::get()->play_music(level_end_song, 0);
-      endsequence_timer.start(7000); // 5 seconds until we finish the map
       tux->invincible_timer.start(7000); //FIXME: Implement a winning timer for the end sequence (with special winning animation etc.)
 
       // add left time to stats
       global_stats.set_points(TIME_NEEDED_STAT, time_left.get_gone() / 1000);
+
+      random_timer.start(200);  // start 1st firework
     }
   else if (!end_sequence && tux->is_dead())
     {
@@ -593,7 +598,8 @@ GameSession::action(double frame_ratio)
   }
 
   // on end sequence make a few fireworks
-  if(end_sequence == ENDSEQUENCE_RUNNING && !random_timer.check())
+  if(end_sequence == ENDSEQUENCE_RUNNING && !random_timer.check() &&
+     currentsector->end_sequence_animation() == FIREWORKS_ENDSEQ_ANIM)
     {
     Vector epicenter = currentsector->camera->get_translation();
     epicenter.x += screen->w * ((float)rand() / RAND_MAX);