From 4cf4c8db6f67b1a85899fada3530e7c6e71de14e Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Sun, 5 Jan 2025 09:31:57 +0100 Subject: [PATCH] =?UTF-8?q?fix:=20arreglada=20la=20acceleraci=C3=B3=20dels?= =?UTF-8?q?=20credits=20sense=20dependre=20de=20vsync?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/credits.cpp | 25 +++++++++++++++---------- source/credits.h | 1 - source/director.cpp | 2 +- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/source/credits.cpp b/source/credits.cpp index 1b605cc..bec003e 100644 --- a/source/credits.cpp +++ b/source/credits.cpp @@ -80,21 +80,27 @@ void Credits::run() // Actualiza las variables void Credits::update() { - if (SDL_GetTicks() - ticks_ > ticks_speed_) + constexpr Uint32 TICKS_SPEED_ = 15; + + if (SDL_GetTicks() - ticks_ > TICKS_SPEED_) { ticks_ = SDL_GetTicks(); - tiled_bg_->update(); - balloon_manager_->update(); - updateTextureDstRects(); - throwBalloons(); - for (auto &player : players_) + const int repeat = want_to_pass_ ? 4 : 1; + for (int i = 0; i < repeat; ++i) { - player->update(); + tiled_bg_->update(); + balloon_manager_->update(); + updateTextureDstRects(); + throwBalloons(); + for (auto &player : players_) + { + player->update(); + } + updateAllFades(); + ++counter_; } - updateAllFades(); Screen::get()->update(); globalInputs::update(); - ++counter_; } } @@ -178,7 +184,6 @@ void Credits::checkInput() { // Si todavía estan los creditos en marcha, se pasan solos a toda pastilla want_to_pass_ = true; - ticks_speed_ = 1; } } diff --git a/source/credits.h b/source/credits.h index 0d5df16..052ee98 100644 --- a/source/credits.h +++ b/source/credits.h @@ -25,7 +25,6 @@ private: // Variables Uint32 ticks_ = 0; // Contador de ticks para ajustar la velocidad del programa - Uint32 ticks_speed_ = 15; // Velocidad del bucle update Uint32 counter_ = 0; // Contador para la lógica de la clase Uint32 counter_pre_fade_ = 0; // Contador para activar el fundido final Uint32 counter_prevent_endless_ = 0; // Contador para evitar que el juego se quede para siempre en los creditos diff --git a/source/director.cpp b/source/director.cpp index 0edbafa..6152130 100644 --- a/source/director.cpp +++ b/source/director.cpp @@ -54,7 +54,7 @@ Director::Director(int argc, const char *argv[]) section::name = section::Name::GAME; section::options = section::Options::GAME_PLAY_1P; #elif DEBUG - section::name = section::Name::GAME; + section::name = section::Name::CREDITS; #else // NORMAL GAME section::name = section::Name::LOGO; section::attract_mode = section::AttractMode::TITLE_TO_DEMO;