#include "object/endsequence_fireworks.hpp"
#include "direction.hpp"
#include "scripting/time_scheduler.hpp"
-
-// the engine will be run with a logical framerate of 64fps.
-// We chose 64fps here because it is a power of 2, so 1/64 gives an "even"
-// binary fraction...
-static const float LOGICAL_FPS = 64.0;
+#include "levelintro.hpp"
enum GameMenuIDs {
MNID_CONTINUE,
end_sequence(0),
levelfile(levelfile_), best_level_statistics(statistics),
capture_demo_stream(0), playback_demo_stream(0), demo_controller(0),
- play_time(0), edit_mode(false)
+ play_time(0), edit_mode(false), levelintro_shown(false)
{
current_ = this;
currentsector = NULL;
currentsector->activate("main");
}
- //levelintro();
-
sound_manager->stop_music();
currentsector->play_music(LEVEL_MUSIC);
}
void
-GameSession::levelintro()
-{
- sound_manager->stop_music();
-
- DrawingContext context;
- for(Sector::GameObjects::iterator i = currentsector->gameobjects.begin();
- i != currentsector->gameobjects.end(); ++i) {
- Background* background = dynamic_cast<Background*> (*i);
- if(background) {
- background->draw(context);
- }
- Gradient* gradient = dynamic_cast<Gradient*> (*i);
- if(gradient) {
- gradient->draw(context);
- }
- }
-
-// context.draw_text(gold_text, level->get_name(), Vector(SCREEN_WIDTH/2, 160),
-// ALIGN_CENTER, LAYER_FOREGROUND1);
- context.draw_center_text(gold_text, level->get_name(), Vector(0, 160),
- LAYER_FOREGROUND1);
-
- std::stringstream ss_coins;
- ss_coins << _("Coins") << ": " << player_status->coins;
- context.draw_text(white_text, ss_coins.str(), Vector(SCREEN_WIDTH/2, 210),
- ALIGN_CENTER, LAYER_FOREGROUND1);
-
- if((level->get_author().size()) && (level->get_author() != "SuperTux Team"))
- context.draw_text(white_small_text,
- std::string(_("contributed by ")) + level->get_author(),
- Vector(SCREEN_WIDTH/2, 350), ALIGN_CENTER, LAYER_FOREGROUND1);
-
- if(best_level_statistics != NULL)
- best_level_statistics->draw_message_info(context, _("Best Level Statistics"));
-
- wait_for_event(1.0, 3.0);
-}
-
-void
GameSession::on_escape_press()
{
if(currentsector->player->is_dying() || end_sequence)
void
GameSession::toggle_pause()
{
+ // pause
if(!game_pause) {
speed_before_pause = main_loop->get_speed();
main_loop->set_speed(0);
Menu::set_current(game_menu.get());
game_menu->set_active_item(MNID_CONTINUE);
game_pause = true;
- } else {
- main_loop->set_speed(speed_before_pause);
- Menu::set_current(NULL);
- game_pause = false;
}
+
+ // unpause is done in update() after the menu is processed
}
void
GameSession::process_events()
{
// end of pause mode?
+ // XXX this looks like a fail-safe to unpause the game if there's no menu
+ // XXX having it enabled causes some unexpected problems
+ // XXX hopefully disabling it won't...
+ /*
if(!Menu::current() && game_pause) {
game_pause = false;
}
+ */
// playback a demo?
if(playback_demo_stream != 0) {
current_ = this;
if(currentsector != Sector::current()) {
- currentsector->activate(currentsector->player->get_pos());
+ currentsector->activate(currentsector->player->get_pos());
}
currentsector->play_music(LEVEL_MUSIC);
SDL_Event event;
while(SDL_PollEvent(&event))
{}
+
+ if (!levelintro_shown) {
+ levelintro_shown = true;
+ main_loop->push_screen(new LevelIntro(level.get(), best_level_statistics));
+ }
}
void
process_events();
process_menu();
+ // Unpause the game if the menu has been closed
+ if (game_pause && !Menu::current()) {
+ main_loop->set_speed(speed_before_pause);
+ game_pause = false;
+ }
+
check_end_conditions();
// respawning in new sector?
// abort if a sequence is already playing
if (end_sequence)
- return;
+ return;
if (sequencename == "endsequence") {
if (currentsector->get_players()[0]->physic.get_velocity_x() < 0) {
// Stop all clocks.
for(std::vector<GameObject*>::iterator i = currentsector->gameobjects.begin();
- i != currentsector->gameobjects.end(); ++i)
+ i != currentsector->gameobjects.end(); ++i)
{
GameObject* obj = *i;