statistics_backdrop.reset(new Surface("images/engine/menu/score-backdrop.png"));
- restart_level(true);
+ restart_level();
game_menu.reset(new Menu());
game_menu->add_label(_("Pause"));
}
void
-GameSession::restart_level(bool fromBeginning)
+GameSession::restart_level()
{
game_pause = false;
end_sequence = 0;
level->stats.total_badguys = level->get_total_badguys();
level->stats.total_secrets = level->get_total_count<SecretAreaTrigger>();
level->stats.reset();
- if (!fromBeginning && (reset_sector != "")) level->stats.declare_invalid();
+ if(reset_sector != "")level->stats.declare_invalid();
- if (fromBeginning) reset_sector="";
if(reset_sector != "") {
currentsector = level->get_sector(reset_sector);
if(!currentsector) {
}
currentsector->activate(reset_pos);
} else {
- player_status->coins += 25;
currentsector = level->get_sector("main");
if(!currentsector)
throw std::runtime_error("Couldn't find main sector");
/* End of level? */
if(end_sequence && end_sequence->is_done()) {
finish(true);
- return;
} else if (!end_sequence && tux->is_dead()) {
- if (player_status->coins < 0) {
- // No more coins: restart level from beginning
- restart_level(true);
- } else {
- // Still has coins: restart level from last reset point
- restart_level(false);
- }
-
- return;
+ restart_level();
}
}
duck = false;
}
} else {
- for (int i = 0; (i < 5) && (i < player_status->coins); i++)
+ if (player_status->coins >= 25 && !GameSession::current()->get_reset_point_sectorname().empty())
{
- // the numbers: starting x, starting y, velocity y
- Sector::current()->add_object(new FallingCoin(get_pos() +
- Vector(systemRandom.rand(5), systemRandom.rand(-32,18)),
- systemRandom.rand(-100,100)));
+ for (int i = 0; i < 5; i++)
+ {
+ // the numbers: starting x, starting y, velocity y
+ Sector::current()->add_object(new FallingCoin(get_pos() +
+ Vector(systemRandom.rand(5), systemRandom.rand(-32,18)),
+ systemRandom.rand(-100,100)));
+ }
+ player_status->coins -= 25;
+ }
+ else
+ {
+ GameSession::current()->set_reset_point("", Vector());
}
physic.enable_gravity(true);
physic.set_acceleration(0, 0);
physic.set_velocity(0, -700);
- player_status->coins -= 25;
set_bonus(NO_BONUS, true);
dying = true;
dying_timer.start(3.0);