From 49be10956014096853b73b20c08d0ffe83a800e7 Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Tue, 19 May 2026 19:32:59 +0200 Subject: [PATCH] demo: Title no consumeix dt quan delega a demo_game (era doble tick, deixava la demo congelada a frame 0) --- source/game/scenes/title.cpp | 62 +++++++++++++++++++----------------- 1 file changed, 32 insertions(+), 30 deletions(-) diff --git a/source/game/scenes/title.cpp b/source/game/scenes/title.cpp index dd2f73a..adfdc1d 100644 --- a/source/game/scenes/title.cpp +++ b/source/game/scenes/title.cpp @@ -853,36 +853,9 @@ void Title::applyOptions() { // Ejecuta un frame void Title::iterate() { - const float DELTA_TIME_S = DeltaTime::tick(); - - // Si las instrucciones están activas, delega el frame - if (instructions_active_) { - instructions_->update(DELTA_TIME_S); - instructions_->render(); - - if (instructions_->hasFinished()) { - bool was_quit = instructions_->isQuitRequested(); - delete instructions_; - instructions_ = nullptr; - instructions_active_ = false; - - if (was_quit) { - section_->name = SECTION_PROG_QUIT; - } else if (instructions_mode_ == Instructions::Mode::AUTO) { - section_->name = SECTION_PROG_TITLE; - init(); - demo_ = true; - } else { - section_->name = SECTION_PROG_TITLE; - section_->subsection = SUBSECTION_TITLE_3; - } - // Reset del rellotge per evitar un dt enorme al tornar al Title. - DeltaTime::reset(); - } - return; - } - - // Si el juego demo está activo, delega el frame + // Si el joc demo està actiu, NO consumim el dt aqui: el consumeix + // Game::iterate() en el seu propi tick(). Cridar-lo dues vegades per frame + // deixaria a Game un dt ~0 i la demo no avancaria (ni jugador ni globus). if (demo_game_active_) { // El demo Game necesita section->name == SECTION_PROG_GAME para funcionar section_->name = SECTION_PROG_GAME; @@ -916,6 +889,35 @@ void Title::iterate() { return; } + const float DELTA_TIME_S = DeltaTime::tick(); + + // Si las instrucciones están activas, delega el frame + if (instructions_active_) { + instructions_->update(DELTA_TIME_S); + instructions_->render(); + + if (instructions_->hasFinished()) { + bool was_quit = instructions_->isQuitRequested(); + delete instructions_; + instructions_ = nullptr; + instructions_active_ = false; + + if (was_quit) { + section_->name = SECTION_PROG_QUIT; + } else if (instructions_mode_ == Instructions::Mode::AUTO) { + section_->name = SECTION_PROG_TITLE; + init(); + demo_ = true; + } else { + section_->name = SECTION_PROG_TITLE; + section_->subsection = SUBSECTION_TITLE_3; + } + // Reset del rellotge per evitar un dt enorme al tornar al Title. + DeltaTime::reset(); + } + return; + } + // Ejecución normal del título update(DELTA_TIME_S); render();