context = new DrawingContext();
- last_swap_point = Vector(-1, -1);
- last_swap_stats.reset();
-
restart_level();
}
global_stats.set_total_points(BADGUYS_KILLED_STAT, level->get_total_badguys());
global_stats.set_total_points(TIME_NEEDED_STAT, level->timelimit);
- currentsector = level->get_sector("main");
- if(!currentsector)
- Termination::abort("Level has no main sector.", "");
- currentsector->activate("main");
-
-#if 0
- // Set Tux to the nearest reset point
- 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));
- }
-#endif
-
- if (st_gl_mode != ST_GL_DEMO_GAME)
- {
- if(st_gl_mode == ST_GL_PLAY || st_gl_mode == ST_GL_LOAD_LEVEL_FILE)
- levelintro();
+ if(reset_sector != "") {
+ currentsector = level->get_sector(reset_sector);
+ if(!currentsector) {
+ std::stringstream msg;
+ msg << "Couldn't find sector '" << reset_sector << "' for resetting tux.";
+ throw std::runtime_error(msg.str());
}
+ currentsector->activate(reset_pos);
+ } else {
+ currentsector = level->get_sector("main");
+ if(!currentsector)
+ throw std::runtime_error("Couldn't find main sector");
+ currentsector->activate("main");
+ }
+
+ if(st_gl_mode == ST_GL_PLAY || st_gl_mode == ST_GL_LOAD_LEVEL_FILE)
+ levelintro();
start_timers();
currentsector->play_music(LEVEL_MUSIC);
}
void
-GameSession::levelintro(void)
+GameSession::levelintro()
{
SoundManager::get()->halt_music();
}
}
- /* Check if chacrater is ASCII */
- char ch[2];
- if((event.key.keysym.unicode & 0xFF80) == 0)
- {
- ch[0] = event.key.keysym.unicode & 0x7F;
- ch[1] = '\0';
- }
+ /* Check if chacrater is ASCII */
+ char ch[2];
+ if((event.key.keysym.unicode & 0xFF80) == 0)
+ {
+ ch[0] = event.key.keysym.unicode & 0x7F;
+ ch[1] = '\0';
+ }
last_keys.append(ch); // add to cheat keys
handle_cheats();
break;
/* End of level? */
if(end_sequence && endsequence_timer.check()) {
- exit_status = ES_LEVEL_FINISHED;
- global_stats += last_swap_stats; // add swap points stats
- return;
+ exit_status = ES_LEVEL_FINISHED;
+ return;
} else if (!end_sequence && tux->is_dead()) {
player_status.bonus = PlayerStatus::NO_BONUS;
}
void
+GameSession::set_reset_point(const std::string& sector, const Vector& pos)
+{
+ reset_sector = sector;
+ reset_pos = pos;
+}
+
+void
GameSession::start_sequence(const std::string& sequencename)
{
if(sequencename == "endsequence" || sequencename == "fireworks") {