corregit audio i timing del game over

This commit is contained in:
2025-09-25 19:36:40 +02:00
parent d1c6af02db
commit 6498c35628
3 changed files with 14 additions and 10 deletions

5
TODO.md Normal file
View File

@@ -0,0 +1,5 @@
# TODO
## Tareas pendientes
- [ ] Revisar todas las variables static de los métodos para ver si se resetean correctamente

View File

@@ -118,6 +118,10 @@ Game::~Game() {
manager->saveToFile(Asset::get()->get("score.bin")); manager->saveToFile(Asset::get()->get("score.bin"));
Section::attract_mode = Section::AttractMode::TITLE_TO_DEMO; Section::attract_mode = Section::AttractMode::TITLE_TO_DEMO;
Audio::get()->stopMusic(); Audio::get()->stopMusic();
if (Options::audio.enabled) {
Audio::get()->stopAllSounds();
Audio::get()->setSoundVolume(Options::audio.sound.volume, Audio::Group::GAME);
}
} }
ServiceMenu::get()->setStateChangeCallback(nullptr); ServiceMenu::get()->setStateChangeCallback(nullptr);
@@ -339,12 +343,11 @@ void Game::updateGameStateGameOver(float deltaTime) {
} }
} }
if (fade_out_->isEnabled()) {
if (Options::audio.enabled) { if (Options::audio.enabled) {
const float VOL = static_cast<float>(64 * (100 - fade_out_->getValue())) / 100.0F; const float progress = std::min(game_over_timer_ / GAME_OVER_DURATION_S, 1.0f);
const float VOL = 64.0f * (1.0f - progress);
Audio::get()->setSoundVolume(static_cast<int>(VOL), Audio::Group::GAME); Audio::get()->setSoundVolume(static_cast<int>(VOL), Audio::Group::GAME);
} }
}
if (fade_out_->hasEnded()) { if (fade_out_->hasEnded()) {
if (game_completed_timer_ > 0) { if (game_completed_timer_ > 0) {
@@ -353,10 +356,6 @@ void Game::updateGameStateGameOver(float deltaTime) {
Section::name = Section::Name::HI_SCORE_TABLE; // La partida ha terminado con la derrota de los jugadores 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;
if (Options::audio.enabled) {
Audio::get()->stopAllSounds();
Audio::get()->setSoundVolume(Options::audio.sound.volume, Audio::Group::GAME);
}
} }
} }

View File

@@ -77,7 +77,7 @@ class Game {
static constexpr float HELP_COUNTER_S = 16.667f; // Contador de ayuda (1000 frames a 60fps → segundos) static constexpr float HELP_COUNTER_S = 16.667f; // Contador de ayuda (1000 frames a 60fps → segundos)
static constexpr float GAME_COMPLETED_START_FADE_S = 8.333f; // Inicio del fade al completar (500 frames → segundos) static constexpr float GAME_COMPLETED_START_FADE_S = 8.333f; // Inicio del fade al completar (500 frames → segundos)
static constexpr float GAME_COMPLETED_END_S = 11.667f; // Fin del juego completado (700 frames → segundos) static constexpr float GAME_COMPLETED_END_S = 11.667f; // Fin del juego completado (700 frames → segundos)
static constexpr float GAME_OVER_DURATION_S = 5.833f; // Duración game over (350 frames → segundos) static constexpr float GAME_OVER_DURATION_S = 7.0f; // Duración game over (350 frames → segundos)
static constexpr float TIME_STOPPED_DURATION_S = 6.0f; // Duración del tiempo detenido (360 frames → segundos) static constexpr float TIME_STOPPED_DURATION_S = 6.0f; // Duración del tiempo detenido (360 frames → segundos)
static constexpr float DEMO_FADE_PRE_DURATION_S = 0.5f; // Pre-duración del fade en modo demo static constexpr float DEMO_FADE_PRE_DURATION_S = 0.5f; // Pre-duración del fade en modo demo
static constexpr int ITEM_POINTS_1_DISK_ODDS = 10; static constexpr int ITEM_POINTS_1_DISK_ODDS = 10;