- return(0);
- } /* if (lives < 0) */
- }
-
- /* Either way, (re-)load the (next) level... */
- tux.level_begin();
- world->set_defaults();
-
- world->get_level()->cleanup();
+ // fallback in case the other endpositions don't trigger
+ if (!end_sequence && tux->base.x >= endpos)
+ {
+ end_sequence = ENDSEQUENCE_WAITING;
+ last_x_pos = -1;
+ music_manager->play_music(level_end_song, 0);
+ endsequence_timer.start(7000);
+ tux->invincible_timer.start(7000); //FIXME: Implement a winning timer for the end sequence (with special winning animation etc.)
+ }
+ else if(end_sequence && !endsequence_timer.check())
+ {
+ exit_status = ES_LEVEL_FINISHED;
+ return;
+ }
+ else if(end_sequence == ENDSEQUENCE_RUNNING && endtile && endtile->data >= 1)
+ {
+ end_sequence = ENDSEQUENCE_WAITING;
+ }
+ else if(!end_sequence && endtile && endtile->data == 0)
+ {
+ end_sequence = ENDSEQUENCE_RUNNING;
+ last_x_pos = -1;
+ music_manager->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.)
+ }
+ else if (!end_sequence && tux->is_dead())
+ {
+ player_status.bonus = PlayerStatus::NO_BONUS;