X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fgameloop.cpp;h=12272310ce8fdbaf838ff91c07ba9ee3931f11ba;hb=8d5a5f453122c39664e534eaef259e59050eba6d;hp=aa5e1c7b9efa3887c9fe97b35c93ad33cb87eb1c;hpb=b83457d64b44e5a3c5071a2f5ecf5c624000f9af;p=supertux.git diff --git a/src/gameloop.cpp b/src/gameloop.cpp index aa5e1c7b9..12272310c 100644 --- a/src/gameloop.cpp +++ b/src/gameloop.cpp @@ -99,6 +99,9 @@ GameSession::GameSession(const std::string& levelname_, int mode, bool flip_leve if(flip_levels_mode) flip_level = true; + last_swap_point = Vector(-1, -1); + last_swap_stats.reset(); + restart_level(); } @@ -129,6 +132,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.", ""); @@ -138,9 +146,19 @@ GameSession::restart_level() if(tux_pos.x != -1) { tux_pos = currentsector->get_best_spawn_point(tux_pos); + + if(last_swap_point.x > tux_pos.x) + tux_pos = last_swap_point; + else // new swap point + { + last_swap_point = tux_pos; + + last_swap_stats += global_stats; + } + currentsector->player->base.x = tux_pos.x; currentsector->player->base.y = tux_pos.y; - + // has to reset camera on swapping currentsector->camera->reset(Vector(currentsector->player->base.x, currentsector->player->base.y)); @@ -152,8 +170,6 @@ GameSession::restart_level() levelintro(); } - global_stats.reset(); - time_left.init(true); start_timers(); currentsector->play_music(LEVEL_MUSIC); @@ -175,8 +191,10 @@ GameSession::levelintro(void) DrawingContext context; currentsector->background->draw(context); - context.draw_text(gold_text, level->get_name(), Vector(screen->w/2, 160), - CENTER_ALLIGN, LAYER_FOREGROUND1); +// context.draw_text(gold_text, level->get_name(), Vector(screen->w/2, 160), +// CENTER_ALLIGN, LAYER_FOREGROUND1); + context.draw_center_text(gold_text, level->get_name(), Vector(0, 160), + LAYER_FOREGROUND1); sprintf(str, "TUX x %d", player_status.lives); context.draw_text(white_text, str, Vector(screen->w/2, 210), @@ -436,7 +454,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(); } @@ -539,6 +558,7 @@ GameSession::check_end_conditions() if(end_sequence && !endsequence_timer.check()) { exit_status = ES_LEVEL_FINISHED; + global_stats += last_swap_stats; // add swap points stats return; } else if(end_sequence == ENDSEQUENCE_RUNNING && endtile && endtile->data >= 1) @@ -948,6 +968,7 @@ bool process_load_game_menu() WorldMapNS::WorldMap worldmap; + worldmap.set_map_filename("icyisland.stwm"); // Load the game or at least set the savegame_file variable worldmap.loadgame(slotfile);