From e3d12e6e276ac7051e16d286faffda10dfb254bf Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Fri, 29 May 2026 22:26:05 +0200 Subject: [PATCH] =?UTF-8?q?feat(titol):=20PRESS=20START=20intermitent=20(l?= =?UTF-8?q?ent=20en=20apar=C3=A8ixer,=20r=C3=A0pid=20en=20pr=C3=A9mer=20ST?= =?UTF-8?q?ART)=20sincronitzat?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/core/defaults/title.hpp | 7 ++++++- source/game/scenes/title_scene.cpp | 19 ++++++++++++------- source/game/scenes/title_scene.hpp | 5 ++++- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/source/core/defaults/title.hpp b/source/core/defaults/title.hpp index c590e99..4546bba 100644 --- a/source/core/defaults/title.hpp +++ b/source/core/defaults/title.hpp @@ -118,7 +118,12 @@ namespace Defaults::Title { constexpr float COPYRIGHT_SCALE = 0.5F; // Escala copyright constexpr float JAILGAMES_BRIGHTNESS = 0.8F; // Logo JAILGAMES una mica menys brillant constexpr float COPYRIGHT_BRIGHTNESS = 0.55F; // Mateix cian que JAILGAMES, però menys brillant - constexpr float JAILGAMES_SCALE = 0.25F; // Escala del logo JAILGAMES pequeño sobre el copyright + + // Parpelleig del "PRESS START" (blinks per segon). Ritme pausat quan el + // text apareix (MAIN) i més ràpid quan ja s'ha premut START (join phase). + constexpr float PRESS_START_BLINK_HZ_SLOW = 1.0F; + constexpr float PRESS_START_BLINK_HZ_FAST = 3.0F; + constexpr float JAILGAMES_SCALE = 0.25F; // Escala del logo JAILGAMES pequeño sobre el copyright // Separación entre el logo JAILGAMES y la línea de copyright (proporción de Game::HEIGHT). constexpr float JAILGAMES_COPYRIGHT_GAP = 0.015F; diff --git a/source/game/scenes/title_scene.cpp b/source/game/scenes/title_scene.cpp index 0755ab2..a2f96dd 100644 --- a/source/game/scenes/title_scene.cpp +++ b/source/game/scenes/title_scene.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include #include "core/audio/audio.hpp" @@ -307,6 +306,7 @@ auto TitleScene::isFinished() const -> bool { } void TitleScene::update(float delta_time) { + blink_timer_ += delta_time; // fase del parpelleig del PRESS START (reiniciada a les transicions) if (starfield_) { starfield_->update(delta_time); } @@ -445,6 +445,7 @@ void TitleScene::updateMainState(float delta_time) { if (!press_start_visible_ && state_time_main_ >= T_PRESS_START_VISIBLE) { press_start_visible_ = true; + blink_timer_ = 0.0F; // primer parpelleig (lent) complet en aparèixer } // L'oscil·lació suau del logo arrenca quan el logo ha aterrat. Així @@ -556,6 +557,7 @@ void TitleScene::handleSkipInput() { intro_jailgames_progress_ = 1.0F; intro_copyright_progress_ = 1.0F; press_start_visible_ = true; + blink_timer_ = 0.0F; // primer parpelleig (lent) complet en saltar la intro ships_intro_launched_ = true; if (ship_animator_ != nullptr) { ship_animator_->setVisible(true); @@ -587,6 +589,7 @@ void TitleScene::handleStartInput() { context_.setMatchConfig(match_config_); current_state_ = TitleState::PLAYER_JOIN_PHASE; temps_acumulat_ = 0.0F; + blink_timer_ = 0.0F; // primer parpelleig (ràpid) complet en passar a join phase triggerExitForJoinedPlayers(P1_ABANS, P2_ABANS, ""); @@ -711,12 +714,14 @@ void TitleScene::draw() { const float SPACING = Defaults::Title::Layout::TEXT_SPACING; if (press_start_visible_) { - bool mostrar_text = true; - if (current_state_ == TitleState::PLAYER_JOIN_PHASE) { - const float FASE = temps_acumulat_ * BLINK_FREQUENCY * 2.0F * std::numbers::pi_v; - mostrar_text = (std::sin(FASE) > 0.0F); - } - if (mostrar_text) { + // Parpelleig: lent en aparèixer (MAIN), ràpid en prémer START (join). + // blink_timer_ es reinicia a 0 a cada transició, així el primer mig + // període és sempre visible i complet (no n'agafa un de parcial). + const float BLINK_HZ = (current_state_ == TitleState::PLAYER_JOIN_PHASE) + ? Defaults::Title::Layout::PRESS_START_BLINK_HZ_FAST + : Defaults::Title::Layout::PRESS_START_BLINK_HZ_SLOW; + const bool MOSTRAR_TEXT = std::fmod(blink_timer_ * BLINK_HZ, 1.0F) < 0.5F; + if (MOSTRAR_TEXT) { const std::string MAIN_TEXT = Locale::get().text("title.press_start"); const float MAIN_SCALE = Defaults::Title::Layout::PRESS_START_SCALE; const float CENTRE_X = Defaults::Game::WIDTH / 2.0F; diff --git a/source/game/scenes/title_scene.hpp b/source/game/scenes/title_scene.hpp index f2af90d..6118e93 100644 --- a/source/game/scenes/title_scene.hpp +++ b/source/game/scenes/title_scene.hpp @@ -110,13 +110,16 @@ class TitleScene final : public Scene { float intro_copyright_progress_{0.0F}; bool press_start_visible_{false}; bool ships_intro_launched_{false}; + // Rellotge de fase del parpelleig del "PRESS START". Es reinicia a 0 en cada + // transició (aparició del text i pas a parpelleig ràpid) perquè el primer + // parpelleig siga sempre un període complet, no un de parcial. + float blink_timer_{0.0F}; static constexpr float BRIGHTNESS_STARFIELD = 1.2F; static constexpr float DURATION_FADE_IN = 3.0F; static constexpr float DURATION_INIT = 4.0F; static constexpr float DURATION_TRANSITION = 2.5F; static constexpr float LETTER_SPACING = 10.0F; - static constexpr float BLINK_FREQUENCY = 3.0F; static constexpr float DURATION_BLACK_SCREEN = 2.0F; static constexpr int MUSIC_FADE = 1500;