void TitleScreen::setup() { Sector* sector = titlesession->get_current_sector(); if(Sector::current() != sector) { sector->play_music(LEVEL_MUSIC); sector->activate(sector->player->get_pos()); } MenuManager::set_current(main_menu.get()); }
void GameSession::update(float elapsed_time) { // Set active flag if(!active) { active = true; } // handle controller if(InputManager::current()->get_controller()->pressed(Controller::ESCAPE) || InputManager::current()->get_controller()->pressed(Controller::START)) { on_escape_press(); } if(InputManager::current()->get_controller()->pressed(Controller::CHEAT_MENU) && g_config->developer_mode) { if (!MenuManager::instance().is_active()) { game_pause = true; MenuManager::instance().set_menu(MenuStorage::CHEAT_MENU); } } process_events(); // Unpause the game if the menu has been closed if (game_pause && !MenuManager::instance().is_active()) { ScreenManager::current()->set_speed(speed_before_pause); SoundManager::current()->resume_music(); SoundManager::current()->resume_sounds(); currentsector->play_looping_sounds(); game_pause = false; } check_end_conditions(); // respawning in new sector? if(!newsector.empty() && !newspawnpoint.empty()) { Sector* sector = level->get_sector(newsector); if(sector == 0) { log_warning << "Sector '" << newsector << "' not found" << std::endl; sector = level->get_sector("main"); } currentsector->stop_looping_sounds(); sector->activate(newspawnpoint); sector->play_music(LEVEL_MUSIC); currentsector = sector; currentsector->play_looping_sounds(); //Keep persistent across sectors if(edit_mode) currentsector->get_players()[0]->set_edit_mode(edit_mode); newsector = ""; newspawnpoint = ""; } // Update the world state and all objects in the world if(!game_pause) { // Update the world if (!end_sequence) { play_time += elapsed_time; //TODO: make sure we don't count cutscene time level->stats.time = play_time; currentsector->update(elapsed_time); } else { if (!end_sequence->is_tux_stopped()) { currentsector->update(elapsed_time); } else { end_sequence->update(elapsed_time); } } } if(currentsector == NULL) return; // update sounds if (currentsector->camera) SoundManager::current()->set_listener_position(currentsector->camera->get_center()); /* Handle music: */ if (end_sequence) return; if(currentsector->player->invincible_timer.started()) { if(currentsector->player->invincible_timer.get_timeleft() <= TUX_INVINCIBLE_TIME_WARNING) { currentsector->play_music(HERRING_WARNING_MUSIC); } else { currentsector->play_music(HERRING_MUSIC); } } else if(currentsector->get_music_type() != LEVEL_MUSIC) { currentsector->play_music(LEVEL_MUSIC); } if (reset_button) { reset_button = false; reset_level(); restart_level(); } }
void GameSession::update(float elapsed_time) { // handle controller if(g_jk_controller->get_main_controller()->pressed(Controller::PAUSE_MENU)) on_escape_press(); process_events(); process_menu(); // Unpause the game if the menu has been closed if (game_pause && !MenuManager::current()) { g_screen_manager->set_speed(speed_before_pause); game_pause = false; } check_end_conditions(); // respawning in new sector? if(newsector != "" && newspawnpoint != "") { Sector* sector = level->get_sector(newsector); if(sector == 0) { log_warning << "Sector '" << newsector << "' not found" << std::endl; sector = level->get_sector("main"); } sector->activate(newspawnpoint); sector->play_music(LEVEL_MUSIC); currentsector = sector; //Keep persistent across sectors if(edit_mode) currentsector->get_players()[0]->set_edit_mode(edit_mode); newsector = ""; newspawnpoint = ""; } // Update the world state and all objects in the world if(!game_pause) { // Update the world if (!end_sequence) { play_time += elapsed_time; //TODO: make sure we don't count cutscene time level->stats.time = play_time; currentsector->update(elapsed_time); } else { if (!end_sequence->is_tux_stopped()) { currentsector->update(elapsed_time); } else { end_sequence->update(elapsed_time); } } } // update sounds if (currentsector && currentsector->camera) sound_manager->set_listener_position(currentsector->camera->get_center()); /* Handle music: */ if (end_sequence) return; if(currentsector->player->invincible_timer.started()) { if(currentsector->player->invincible_timer.get_timeleft() <= TUX_INVINCIBLE_TIME_WARNING) { currentsector->play_music(HERRING_WARNING_MUSIC); } else { currentsector->play_music(HERRING_MUSIC); } } else if(currentsector->get_music_type() != LEVEL_MUSIC) { currentsector->play_music(LEVEL_MUSIC); } }