From 6fae12ba0261d968fcce1bbb6eb3e4347f2be28f Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Tue, 30 Sep 2025 19:59:38 +0200 Subject: [PATCH] fix: la ultima tarjeta de la intro no tenia temps de repos --- source/director.cpp | 2 +- source/sections/intro.cpp | 22 +++++++++++----------- source/sections/intro.h | 4 ++-- source/sections/title.cpp | 12 ++++++++---- source/sections/title.h | 2 +- 5 files changed, 23 insertions(+), 19 deletions(-) diff --git a/source/director.cpp b/source/director.cpp index 29e9e3f..3a3c8bc 100644 --- a/source/director.cpp +++ b/source/director.cpp @@ -42,7 +42,7 @@ Director::Director(int argc, std::span argv) { Section::name = Section::Name::GAME; Section::options = Section::Options::GAME_PLAY_1P; #elif _DEBUG - Section::name = Section::Name::TITLE; + Section::name = Section::Name::LOGO; Section::options = Section::Options::GAME_PLAY_1P; #else // NORMAL GAME Section::name = Section::Name::LOGO; diff --git a/source/sections/intro.cpp b/source/sections/intro.cpp index 6489e32..0cc2ac4 100644 --- a/source/sections/intro.cpp +++ b/source/sections/intro.cpp @@ -208,7 +208,7 @@ void Intro::switchText(int from_index, int to_index) { // Actualiza las variables del objeto void Intro::update(float delta_time) { - static auto *const SCREEN = Screen::get(); + static auto* const SCREEN = Screen::get(); SCREEN->update(delta_time); // Actualiza el objeto screen Audio::update(); // Actualiza el objeto Audio @@ -229,7 +229,7 @@ void Intro::update(float delta_time) { // Dibuja el objeto en pantalla void Intro::render() { - static auto *const SCREEN = Screen::get(); + static auto* const SCREEN = Screen::get(); SCREEN->start(); // Prepara para empezar a dibujar en la textura de juego SCREEN->clean(); // Limpia la pantalla @@ -302,7 +302,7 @@ void Intro::initSprites() { card_texture->setBlendMode(SDL_BLENDMODE_BLEND); // Apuntamos el renderizador a la textura - auto *temp = SDL_GetRenderTarget(Screen::get()->getRenderer()); + auto* temp = SDL_GetRenderTarget(Screen::get()->getRenderer()); card_texture->setAsRenderTarget(Screen::get()->getRenderer()); // Limpia la textura @@ -343,7 +343,7 @@ void Intro::initSprites() { card_sprites_.at(2)->addPath(-CARD_HEIGHT, Y_DEST, PathType::VERTICAL, X_DEST, CARD_ANIM_DURATION_FAST, easeOutQuint, 0.0f); card_sprites_.at(3)->addPath(param.game.height, Y_DEST, PathType::VERTICAL, X_DEST, CARD_ANIM_DURATION_VERY_SLOW, easeInOutExpo, 0.0f); card_sprites_.at(4)->addPath(-CARD_HEIGHT, Y_DEST, PathType::VERTICAL, X_DEST, CARD_ANIM_DURATION_MEDIUM, easeOutElastic, 0.0f); - card_sprites_.at(5)->addPath(-CARD_HEIGHT, Y_DEST, PathType::VERTICAL, X_DEST, CARD_ANIM_DURATION_SLOW, easeOutQuad, CARD_ANIM_DELAY_LONG); + card_sprites_.at(5)->addPath(-CARD_HEIGHT, Y_DEST, PathType::VERTICAL, X_DEST, CARD_ANIM_DURATION_SLOW, easeOutQuad, CARD_ANIM_DELAY_LONG_S); card_sprites_.at(5)->addPath(X_DEST, -CARD_WIDTH, PathType::HORIZONTAL, Y_DEST, CARD_ANIM_DURATION_SHORT, easeInElastic, 0.0f); // Constantes @@ -357,7 +357,7 @@ void Intro::initSprites() { shadow_texture->setBlendMode(SDL_BLENDMODE_BLEND); // Apuntamos el renderizador a la textura - auto *temp = SDL_GetRenderTarget(Screen::get()->getRenderer()); + auto* temp = SDL_GetRenderTarget(Screen::get()->getRenderer()); shadow_texture->setAsRenderTarget(Screen::get()->getRenderer()); // Limpia la textura @@ -394,7 +394,7 @@ void Intro::initSprites() { shadow_sprites_.at(2)->addPath(-SHADOW_SPRITE_WIDTH, S_X_DEST, PathType::HORIZONTAL, S_Y_DEST, CARD_ANIM_DURATION_FAST, easeOutQuint, 0.0f); shadow_sprites_.at(3)->addPath(-SHADOW_SPRITE_HEIGHT, S_Y_DEST, PathType::VERTICAL, S_X_DEST, CARD_ANIM_DURATION_VERY_SLOW, easeInOutExpo, 0.0f); shadow_sprites_.at(4)->addPath(param.game.height, S_Y_DEST, PathType::VERTICAL, S_X_DEST, CARD_ANIM_DURATION_MEDIUM, easeOutElastic, 0.0f); - shadow_sprites_.at(5)->addPath(param.game.width, S_X_DEST, PathType::HORIZONTAL, S_Y_DEST, CARD_ANIM_DURATION_SLOW, easeOutQuad, CARD_ANIM_DELAY_LONG); + shadow_sprites_.at(5)->addPath(param.game.width, S_X_DEST, PathType::HORIZONTAL, S_Y_DEST, CARD_ANIM_DURATION_SLOW, easeOutQuad, CARD_ANIM_DELAY_LONG_S); shadow_sprites_.at(5)->addPath(S_X_DEST, param.game.width, PathType::HORIZONTAL, S_Y_DEST, CARD_ANIM_DURATION_SHORT, easeInElastic, 0.0f); } @@ -447,25 +447,25 @@ void Intro::initTexts() { texts_.at(8)->setCaption(Lang::getText("[INTRO] 9")); texts_.at(8)->setSpeedS(TEXT_SPEED_ULTRA_FAST); - for (auto &text : texts_) { + for (auto& text : texts_) { text->center(param.game.game_area.center_x); } } // Actualiza los sprites void Intro::updateSprites(float delta_time) { - for (auto &sprite : card_sprites_) { + for (auto& sprite : card_sprites_) { sprite->update(delta_time); } - for (auto &sprite : shadow_sprites_) { + for (auto& sprite : shadow_sprites_) { sprite->update(delta_time); } } // Actualiza los textos void Intro::updateTexts(float delta_time) { - for (auto &text : texts_) { + for (auto& text : texts_) { text->updateS(delta_time); // Usar updateS para delta_time en segundos } } @@ -478,7 +478,7 @@ void Intro::renderSprites() { // Dibuja los textos void Intro::renderTexts() { - for (const auto &text : texts_) { + for (const auto& text : texts_) { text->render(); } } diff --git a/source/sections/intro.h b/source/sections/intro.h index 8cd36cb..161b715 100644 --- a/source/sections/intro.h +++ b/source/sections/intro.h @@ -65,8 +65,8 @@ class Intro { static constexpr float CARD_ANIM_DURATION_SLOW = 250.0f / 60.0f; // ≈ 4.1667 s static constexpr float CARD_ANIM_DURATION_VERY_SLOW = 300.0f / 60.0f; // ≈ 5.0000 s - static constexpr float CARD_ANIM_DELAY_LONG = 0.45f; // Retraso largo antes de animación - static constexpr float CARD_OFFSET_MARGIN = 10.0f; // Margen fuera de pantalla + static constexpr float CARD_ANIM_DELAY_LONG_S = 7.5F; // Retraso largo antes de animación + static constexpr float CARD_OFFSET_MARGIN = 10.0F; // Margen fuera de pantalla // --- Estados internos --- enum class State { diff --git a/source/sections/title.cpp b/source/sections/title.cpp index 75a3de2..34ba844 100644 --- a/source/sections/title.cpp +++ b/source/sections/title.cpp @@ -91,10 +91,7 @@ void Title::update(float deltaTime) { updateFade(); updateState(deltaTime); updateStartPrompt(deltaTime); - - for (auto& player : players_) { - player->update(deltaTime); - } + updatePlayers(deltaTime); } // Calcula el tiempo transcurrido desde el último frame @@ -569,6 +566,13 @@ void Title::initPlayers() { } } +// Actualiza los jugadores +void Title::updatePlayers(float deltaTime) { + for (auto& player : players_) { + player->update(deltaTime); + } +} + // Renderiza los jugadores void Title::renderPlayers() { for (auto const& player : players_) { diff --git a/source/sections/title.h b/source/sections/title.h index a1d5d2b..6f2c3e3 100644 --- a/source/sections/title.h +++ b/source/sections/title.h @@ -125,7 +125,7 @@ class Title { // --- Gestión de jugadores --- void initPlayers(); // Inicializa los jugadores - void updatePlayers(); // Actualiza los jugadores + void updatePlayers(float deltaTime); // Actualiza los jugadores void renderPlayers(); // Renderiza los jugadores auto getPlayer(Player::Id id) -> std::shared_ptr; // Obtiene un jugador a partir de su "id"