corregit audio de timeStopItem

This commit is contained in:
2025-09-24 18:26:39 +02:00
parent d077374883
commit ec65ff9acb

View File

@@ -869,15 +869,27 @@ void Game::updateTimeStopped(float deltaTime) {
// Fase de advertencia (últimos 2 segundos)
if (time_stopped_timer_ <= WARNING_THRESHOLD_S) {
static float last_sound_time = 0.0f;
static bool color_flash_sound_played = false;
static bool warning_phase_started = false;
// CLAC al entrar en fase de advertencia
if (!warning_phase_started) {
playSound("clock.wav");
warning_phase_started = true;
last_sound_time = 0.0f; // Reset para empezar el ciclo rápido
}
last_sound_time += deltaTime;
if (last_sound_time >= CLOCK_SOUND_INTERVAL_S) {
balloon_manager_->normalColorsToAllBalloons();
playSound("clock.wav");
last_sound_time = 0.0f;
} else if (last_sound_time >= COLOR_FLASH_INTERVAL_S) {
color_flash_sound_played = false; // Reset flag para el próximo intervalo
} else if (last_sound_time >= COLOR_FLASH_INTERVAL_S && !color_flash_sound_played) {
balloon_manager_->reverseColorsToAllBalloons();
playSound("clock.wav");
color_flash_sound_played = true; // Evita que suene múltiples veces
}
} else {
// Fase normal - solo sonido ocasional
@@ -888,8 +900,12 @@ void Game::updateTimeStopped(float deltaTime) {
sound_timer = 0.0f;
}
}
} else {
disableTimeStopItem();
// Si el timer llega a 0 o menos, desactivar
if (time_stopped_timer_ <= 0) {
playSound("clock.wav"); // CLAC final
disableTimeStopItem();
}
}
}