feat(titol): PRESS START intermitent (lent en aparèixer, ràpid en prémer START) sincronitzat

This commit is contained in:
2026-05-29 22:26:05 +02:00
parent 47e9d85708
commit e3d12e6e27
3 changed files with 22 additions and 9 deletions
+6 -1
View File
@@ -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;
+12 -7
View File
@@ -7,7 +7,6 @@
#include <cfloat>
#include <cmath>
#include <iostream>
#include <numbers>
#include <string>
#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<float>;
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;
+4 -1
View File
@@ -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;