fix: arreglada la acceleració dels credits sense dependre de vsync

This commit is contained in:
2025-01-05 09:31:57 +01:00
parent cd806363e8
commit 4cf4c8db6f
3 changed files with 16 additions and 12 deletions

View File

@@ -80,9 +80,14 @@ 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();
const int repeat = want_to_pass_ ? 4 : 1;
for (int i = 0; i < repeat; ++i)
{
tiled_bg_->update();
balloon_manager_->update();
updateTextureDstRects();
@@ -92,9 +97,10 @@ void Credits::update()
player->update();
}
updateAllFades();
++counter_;
}
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;
}
}

View File

@@ -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

View File

@@ -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;