demo: Title no consumeix dt quan delega a demo_game (era doble tick, deixava la demo congelada a frame 0)

This commit is contained in:
2026-05-19 19:32:59 +02:00
parent 63eaaa8b5c
commit 49be109560
+32 -30
View File
@@ -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();