fix: ja no s'escolta el time stopper al passar-se el joc
style: ja no ix el lletrero de gameover al passar-se el joc
This commit is contained in:
@@ -370,17 +370,14 @@ void Game::updateGameStateGameOver(float delta_time) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (fade_out_->hasEnded()) {
|
if (fade_out_->hasEnded()) {
|
||||||
if (game_completed_timer_ > 0) {
|
Section::name = Section::Name::HI_SCORE_TABLE;
|
||||||
Section::name = Section::Name::CREDITS; // Los jugadores han completado el juego
|
|
||||||
} else {
|
|
||||||
Section::name = Section::Name::HI_SCORE_TABLE; // La partida ha terminado con la derrota de los jugadores
|
|
||||||
}
|
|
||||||
Section::options = Section::Options::HI_SCORE_AFTER_PLAYING;
|
Section::options = Section::Options::HI_SCORE_AFTER_PLAYING;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gestiona eventos para el estado del final del juego
|
// Gestiona eventos para el estado del final del juego
|
||||||
void Game::updateGameStateCompleted(float delta_time) {
|
void Game::updateGameStateCompleted(float delta_time) {
|
||||||
|
fade_out_->update();
|
||||||
updatePlayers(delta_time);
|
updatePlayers(delta_time);
|
||||||
updateScoreboard(delta_time);
|
updateScoreboard(delta_time);
|
||||||
updateBackground(delta_time);
|
updateBackground(delta_time);
|
||||||
@@ -397,7 +394,12 @@ void Game::updateGameStateCompleted(float delta_time) {
|
|||||||
|
|
||||||
// Si los jugadores ya no estan y no quedan mensajes en pantalla
|
// Si los jugadores ya no estan y no quedan mensajes en pantalla
|
||||||
if (allPlayersAreGameOver() && path_sprites_.empty()) {
|
if (allPlayersAreGameOver() && path_sprites_.empty()) {
|
||||||
setState(State::GAME_OVER);
|
fade_out_->activate();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fade_out_->hasEnded()) {
|
||||||
|
Section::name = Section::Name::CREDITS;
|
||||||
|
Section::options = Section::Options::HI_SCORE_AFTER_PLAYING;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Incrementa el acumulador al final
|
// Incrementa el acumulador al final
|
||||||
@@ -823,43 +825,41 @@ void Game::handlePlayerCollision(std::shared_ptr<Player>& player, std::shared_pt
|
|||||||
|
|
||||||
// Actualiza el estado del tiempo detenido
|
// Actualiza el estado del tiempo detenido
|
||||||
void Game::updateTimeStopped(float delta_time) {
|
void Game::updateTimeStopped(float delta_time) {
|
||||||
static constexpr float WARNING_THRESHOLD_S = 2.0F; // 120 frames a 60fps → segundos
|
static constexpr float WARNING_THRESHOLD_S = 2.0F;
|
||||||
static constexpr float CLOCK_SOUND_INTERVAL_S = 0.5F; // 30 frames a 60fps → segundos
|
static constexpr float CLOCK_SOUND_INTERVAL_S = 0.5F;
|
||||||
static constexpr float COLOR_FLASH_INTERVAL_S = 0.25F; // 15 frames a 60fps → segundos
|
static constexpr float COLOR_FLASH_INTERVAL_S = 0.25F;
|
||||||
|
|
||||||
if (time_stopped_timer_ > 0) {
|
if (time_stopped_timer_ > 0) {
|
||||||
time_stopped_timer_ -= delta_time;
|
time_stopped_timer_ -= delta_time;
|
||||||
|
|
||||||
// Fase de advertencia (últimos 2 segundos)
|
// Fase de advertencia (últimos 2 segundos)
|
||||||
if (time_stopped_timer_ <= WARNING_THRESHOLD_S) {
|
if (time_stopped_timer_ <= WARNING_THRESHOLD_S) {
|
||||||
static float last_sound_time_ = 0.0F;
|
|
||||||
|
|
||||||
// CLAC al entrar en fase de advertencia
|
// CLAC al entrar en fase de advertencia
|
||||||
if (!time_stopped_flags_.warning_phase_started) {
|
if (!time_stopped_flags_.warning_phase_started) {
|
||||||
playSound("clock.wav");
|
playSound("clock.wav");
|
||||||
time_stopped_flags_.warning_phase_started = true;
|
time_stopped_flags_.warning_phase_started = true;
|
||||||
last_sound_time_ = 0.0F; // Reset para empezar el ciclo rápido
|
time_stopped_sound_timer_ = 0.0F; // Reset para empezar el ciclo rápido
|
||||||
}
|
}
|
||||||
|
|
||||||
last_sound_time_ += delta_time;
|
time_stopped_sound_timer_ += delta_time;
|
||||||
|
|
||||||
if (last_sound_time_ >= CLOCK_SOUND_INTERVAL_S) {
|
if (time_stopped_sound_timer_ >= CLOCK_SOUND_INTERVAL_S) {
|
||||||
balloon_manager_->normalColorsToAllBalloons();
|
balloon_manager_->normalColorsToAllBalloons();
|
||||||
playSound("clock.wav");
|
playSound("clock.wav");
|
||||||
last_sound_time_ = 0.0F;
|
time_stopped_sound_timer_ = 0.0F;
|
||||||
time_stopped_flags_.color_flash_sound_played = false; // Reset flag para el próximo intervalo
|
time_stopped_flags_.color_flash_sound_played = false; // Reset flag para el próximo intervalo
|
||||||
} else if (last_sound_time_ >= COLOR_FLASH_INTERVAL_S && !time_stopped_flags_.color_flash_sound_played) {
|
} else if (time_stopped_sound_timer_ >= COLOR_FLASH_INTERVAL_S && !time_stopped_flags_.color_flash_sound_played) {
|
||||||
balloon_manager_->reverseColorsToAllBalloons();
|
balloon_manager_->reverseColorsToAllBalloons();
|
||||||
playSound("clock.wav");
|
playSound("clock.wav");
|
||||||
time_stopped_flags_.color_flash_sound_played = true; // Evita que suene múltiples veces
|
time_stopped_flags_.color_flash_sound_played = true; // Evita que suene múltiples veces
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// Fase normal - solo sonido ocasional
|
// Fase normal - solo sonido ocasional
|
||||||
static float sound_timer_ = 0.0F;
|
time_stopped_sound_timer_ += delta_time;
|
||||||
sound_timer_ += delta_time;
|
if (time_stopped_sound_timer_ >= CLOCK_SOUND_INTERVAL_S) {
|
||||||
if (sound_timer_ >= CLOCK_SOUND_INTERVAL_S) {
|
|
||||||
playSound("clock.wav");
|
playSound("clock.wav");
|
||||||
sound_timer_ = 0.0F;
|
time_stopped_sound_timer_ = 0.0F;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -959,12 +959,14 @@ void Game::enableTimeStopItem() {
|
|||||||
balloon_manager_->stopAllBalloons();
|
balloon_manager_->stopAllBalloons();
|
||||||
balloon_manager_->reverseColorsToAllBalloons();
|
balloon_manager_->reverseColorsToAllBalloons();
|
||||||
time_stopped_timer_ = TIME_STOPPED_DURATION_S;
|
time_stopped_timer_ = TIME_STOPPED_DURATION_S;
|
||||||
|
time_stopped_sound_timer_ = 0.0F;
|
||||||
time_stopped_flags_.reset(); // Resetea flags al activar el item
|
time_stopped_flags_.reset(); // Resetea flags al activar el item
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deshabilita el efecto del item de detener el tiempo
|
// Deshabilita el efecto del item de detener el tiempo
|
||||||
void Game::disableTimeStopItem() {
|
void Game::disableTimeStopItem() {
|
||||||
time_stopped_timer_ = 0;
|
time_stopped_timer_ = 0.0F;
|
||||||
|
time_stopped_sound_timer_ = 0.0F;
|
||||||
balloon_manager_->startAllBalloons();
|
balloon_manager_->startAllBalloons();
|
||||||
balloon_manager_->normalColorsToAllBalloons();
|
balloon_manager_->normalColorsToAllBalloons();
|
||||||
}
|
}
|
||||||
@@ -1884,6 +1886,7 @@ void Game::setState(State state) {
|
|||||||
case State::COMPLETED: // Para la música y elimina todos los globos e items
|
case State::COMPLETED: // Para la música y elimina todos los globos e items
|
||||||
stopMusic(); // Detiene la música
|
stopMusic(); // Detiene la música
|
||||||
balloon_manager_->destroyAllBalloons(); // Destruye a todos los globos
|
balloon_manager_->destroyAllBalloons(); // Destruye a todos los globos
|
||||||
|
disableTimeStopItem(); // Deshabilita el temporizador de tiempo
|
||||||
playSound("power_ball_explosion.wav"); // Sonido de destruir todos los globos
|
playSound("power_ball_explosion.wav"); // Sonido de destruir todos los globos
|
||||||
destroyAllItems(); // Destruye todos los items
|
destroyAllItems(); // Destruye todos los items
|
||||||
background_->setAlpha(0); // Elimina el tono rojo de las últimas pantallas
|
background_->setAlpha(0); // Elimina el tono rojo de las últimas pantallas
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ class Game {
|
|||||||
|
|
||||||
std::vector<std::shared_ptr<Texture>> game_text_textures_; // Vector con las texturas para los sprites con textos
|
std::vector<std::shared_ptr<Texture>> game_text_textures_; // Vector con las texturas para los sprites con textos
|
||||||
|
|
||||||
std::vector<std::vector<std::string>> item_animations_; // Vector con las animaciones de los items
|
std::vector<std::vector<std::string>> item_animations_; // Vector con las animaciones de los items
|
||||||
std::vector<std::vector<std::string>> player1_animations_; // Vector con las animaciones del jugador 1
|
std::vector<std::vector<std::string>> player1_animations_; // Vector con las animaciones del jugador 1
|
||||||
std::vector<std::vector<std::string>> player2_animations_; // Vector con las animaciones del jugador 2
|
std::vector<std::vector<std::string>> player2_animations_; // Vector con las animaciones del jugador 2
|
||||||
|
|
||||||
@@ -163,6 +163,7 @@ class Game {
|
|||||||
float game_completed_timer_ = 0.0F; // Acumulador de tiempo para el tramo final (milisegundos)
|
float game_completed_timer_ = 0.0F; // Acumulador de tiempo para el tramo final (milisegundos)
|
||||||
float game_over_timer_ = 0.0F; // Timer para el estado de fin de partida (milisegundos)
|
float game_over_timer_ = 0.0F; // Timer para el estado de fin de partida (milisegundos)
|
||||||
float time_stopped_timer_ = 0.0F; // Temporizador para llevar la cuenta del tiempo detenido
|
float time_stopped_timer_ = 0.0F; // Temporizador para llevar la cuenta del tiempo detenido
|
||||||
|
float time_stopped_sound_timer_ = 0.0F; // Temporizador para controlar el sonido del tiempo detenido
|
||||||
int menace_ = 0; // Nivel de amenaza actual
|
int menace_ = 0; // Nivel de amenaza actual
|
||||||
int menace_threshold_ = 0; // Umbral del nivel de amenaza. Si el nivel de amenaza cae por debajo del umbral, se generan más globos. Si el umbral aumenta, aumenta el número de globos
|
int menace_threshold_ = 0; // Umbral del nivel de amenaza. Si el nivel de amenaza cae por debajo del umbral, se generan más globos. Si el umbral aumenta, aumenta el número de globos
|
||||||
State state_ = State::FADE_IN; // Estado
|
State state_ = State::FADE_IN; // Estado
|
||||||
|
|||||||
Reference in New Issue
Block a user