style: aplicar readability-uppercase-literal-suffix

- Cambiar todos los literales float de minúscula a mayúscula (1.0f → 1.0F)
- 657 correcciones aplicadas automáticamente con clang-tidy
- Check 1/N completado

🤖 Generated with Claude Code
This commit is contained in:
2025-12-18 13:06:48 +01:00
parent 44cd0857e0
commit bc94eff176
41 changed files with 705 additions and 594 deletions

View File

@@ -72,12 +72,12 @@ void EscenaJoc::executar() {
while (GestorEscenes::actual == Escena::JOC) {
// Calcular delta_time real
Uint64 current_time = SDL_GetTicks();
float delta_time = (current_time - last_time) / 1000.0f;
float delta_time = (current_time - last_time) / 1000.0F;
last_time = current_time;
// Limitar delta_time per evitar grans salts
if (delta_time > 0.05f) {
delta_time = 0.05f;
if (delta_time > 0.05F) {
delta_time = 0.05F;
}
// Actualitzar comptador de FPS
@@ -147,17 +147,17 @@ void EscenaJoc::inicialitzar() {
stage_manager_->get_spawn_controller().set_ship_position(&naus_[0].get_centre());
// Inicialitzar timers de muerte per jugador
itocado_per_jugador_[0] = 0.0f;
itocado_per_jugador_[1] = 0.0f;
itocado_per_jugador_[0] = 0.0F;
itocado_per_jugador_[1] = 0.0F;
// Initialize lives and game over state (independent lives per player)
vides_per_jugador_[0] = Defaults::Game::STARTING_LIVES;
vides_per_jugador_[1] = Defaults::Game::STARTING_LIVES;
estat_game_over_ = EstatGameOver::NONE;
continue_counter_ = 0;
continue_tick_timer_ = 0.0f;
continue_tick_timer_ = 0.0F;
continues_usados_ = 0;
game_over_timer_ = 0.0f;
game_over_timer_ = 0.0F;
// Initialize scores (separate per player)
puntuacio_per_jugador_[0] = 0;
@@ -181,7 +181,7 @@ void EscenaJoc::inicialitzar() {
} else {
// Jugador inactiu: marcar com a mort permanent
naus_[i].marcar_tocada();
itocado_per_jugador_[i] = 999.0f; // Valor sentinella (permanent inactiu)
itocado_per_jugador_[i] = 999.0F; // Valor sentinella (permanent inactiu)
vides_per_jugador_[i] = 0; // Sense vides
std::cout << "[EscenaJoc] Jugador " << (i + 1) << " inactiu\n";
}
@@ -231,10 +231,10 @@ void EscenaJoc::actualitzar(float delta_time) {
if (stage_manager_->get_estat() == StageSystem::EstatStage::PLAYING) {
// Check if at least one player is alive and playing (game in progress)
bool algun_jugador_viu = false;
if (config_partida_.jugador1_actiu && itocado_per_jugador_[0] != 999.0f) {
if (config_partida_.jugador1_actiu && itocado_per_jugador_[0] != 999.0F) {
algun_jugador_viu = true;
}
if (config_partida_.jugador2_actiu && itocado_per_jugador_[1] != 999.0f) {
if (config_partida_.jugador2_actiu && itocado_per_jugador_[1] != 999.0F) {
algun_jugador_viu = true;
}
@@ -242,7 +242,7 @@ void EscenaJoc::actualitzar(float delta_time) {
if (algun_jugador_viu) {
// P2 can join if not currently playing (never joined OR dead without lives)
bool p2_no_juga = !config_partida_.jugador2_actiu || // Never joined
itocado_per_jugador_[1] == 999.0f; // Dead without lives
itocado_per_jugador_[1] == 999.0F; // Dead without lives
if (p2_no_juga) {
if (input->checkActionPlayer2(InputAction::START, Input::DO_NOT_ALLOW_REPEAT)) {
@@ -252,7 +252,7 @@ void EscenaJoc::actualitzar(float delta_time) {
// P1 can join if not currently playing (never joined OR dead without lives)
bool p1_no_juga = !config_partida_.jugador1_actiu || // Never joined
itocado_per_jugador_[0] == 999.0f; // Dead without lives
itocado_per_jugador_[0] == 999.0F; // Dead without lives
if (p1_no_juga) {
if (input->checkActionPlayer1(InputAction::START, Input::DO_NOT_ALLOW_REPEAT)) {
@@ -285,7 +285,7 @@ void EscenaJoc::actualitzar(float delta_time) {
// Game over: only update timer, enemies, bullets, and debris
game_over_timer_ -= delta_time;
if (game_over_timer_ <= 0.0f) {
if (game_over_timer_ <= 0.0F) {
// Aturar música de joc abans de tornar al títol
Audio::get()->stopMusic();
// Transició a pantalla de títol
@@ -311,7 +311,7 @@ void EscenaJoc::actualitzar(float delta_time) {
// Check death sequence state for BOTH players
bool algun_jugador_mort = false;
for (uint8_t i = 0; i < 2; i++) {
if (itocado_per_jugador_[i] > 0.0f && itocado_per_jugador_[i] < 999.0f) {
if (itocado_per_jugador_[i] > 0.0F && itocado_per_jugador_[i] < 999.0F) {
algun_jugador_mort = true;
// Death sequence active: update timer
itocado_per_jugador_[i] += delta_time;
@@ -327,11 +327,11 @@ void EscenaJoc::actualitzar(float delta_time) {
// Respawn ship en spawn position con invulnerabilidad
Punt spawn_pos = obtenir_punt_spawn(i);
naus_[i].inicialitzar(&spawn_pos, true);
itocado_per_jugador_[i] = 0.0f;
itocado_per_jugador_[i] = 0.0F;
} else {
// Player is permanently dead (out of lives)
// Set sentinel value to prevent re-entering this block
itocado_per_jugador_[i] = 999.0f;
itocado_per_jugador_[i] = 999.0F;
// Check if ALL ACTIVE players are dead (trigger continue screen)
bool p1_dead = !config_partida_.jugador1_actiu || vides_per_jugador_[0] <= 0;
@@ -380,8 +380,8 @@ void EscenaJoc::actualitzar(float delta_time) {
}
// Calcular global progress (0.0 al inicio → 1.0 al final)
float global_progress = 1.0f - (stage_manager_->get_timer_transicio() / Defaults::Game::INIT_HUD_DURATION);
global_progress = std::min(1.0f, global_progress);
float global_progress = 1.0F - (stage_manager_->get_timer_transicio() / Defaults::Game::INIT_HUD_DURATION);
global_progress = std::min(1.0F, global_progress);
// [NEW] Calcular progress independiente para cada nave
float ship1_progress = calcular_progress_rango(
@@ -395,12 +395,12 @@ void EscenaJoc::actualitzar(float delta_time) {
Defaults::Game::INIT_HUD_SHIP2_RATIO_END);
// [MODIFICAT] Animar AMBAS naus con sus progress respectivos
if (config_partida_.jugador1_actiu && ship1_progress < 1.0f) {
if (config_partida_.jugador1_actiu && ship1_progress < 1.0F) {
Punt pos_p1 = calcular_posicio_nau_init_hud(ship1_progress, 0);
naus_[0].set_centre(pos_p1);
}
if (config_partida_.jugador2_actiu && ship2_progress < 1.0f) {
if (config_partida_.jugador2_actiu && ship2_progress < 1.0F) {
Punt pos_p2 = calcular_posicio_nau_init_hud(ship2_progress, 1);
naus_[1].set_centre(pos_p2);
}
@@ -425,7 +425,7 @@ void EscenaJoc::actualitzar(float delta_time) {
// [NEW] Allow both ships movement and shooting during intro
for (uint8_t i = 0; i < 2; i++) {
bool jugador_actiu = (i == 0) ? config_partida_.jugador1_actiu : config_partida_.jugador2_actiu;
if (jugador_actiu && itocado_per_jugador_[i] == 0.0f) { // Only active, alive players
if (jugador_actiu && itocado_per_jugador_[i] == 0.0F) { // Only active, alive players
naus_[i].processar_input(delta_time, i);
naus_[i].actualitzar(delta_time);
}
@@ -443,11 +443,11 @@ void EscenaJoc::actualitzar(float delta_time) {
case StageSystem::EstatStage::PLAYING: {
// [NEW] Update stage manager (spawns enemies, pause if BOTH dead)
bool pausar_spawn = (itocado_per_jugador_[0] > 0.0f && itocado_per_jugador_[1] > 0.0f);
bool pausar_spawn = (itocado_per_jugador_[0] > 0.0F && itocado_per_jugador_[1] > 0.0F);
stage_manager_->get_spawn_controller().actualitzar(delta_time, orni_, pausar_spawn);
// [NEW] Check stage completion (only when at least one player alive)
bool algun_jugador_viu = (itocado_per_jugador_[0] == 0.0f || itocado_per_jugador_[1] == 0.0f);
bool algun_jugador_viu = (itocado_per_jugador_[0] == 0.0F || itocado_per_jugador_[1] == 0.0F);
if (algun_jugador_viu) {
auto& spawn_ctrl = stage_manager_->get_spawn_controller();
if (spawn_ctrl.tots_enemics_destruits(orni_)) {
@@ -460,7 +460,7 @@ void EscenaJoc::actualitzar(float delta_time) {
// [EXISTING] Normal gameplay - update active players
for (uint8_t i = 0; i < 2; i++) {
bool jugador_actiu = (i == 0) ? config_partida_.jugador1_actiu : config_partida_.jugador2_actiu;
if (jugador_actiu && itocado_per_jugador_[i] == 0.0f) { // Only active, alive players
if (jugador_actiu && itocado_per_jugador_[i] == 0.0F) { // Only active, alive players
naus_[i].processar_input(delta_time, i);
naus_[i].actualitzar(delta_time);
}
@@ -489,7 +489,7 @@ void EscenaJoc::actualitzar(float delta_time) {
// [NEW] Allow both ships movement and shooting during outro
for (uint8_t i = 0; i < 2; i++) {
bool jugador_actiu = (i == 0) ? config_partida_.jugador1_actiu : config_partida_.jugador2_actiu;
if (jugador_actiu && itocado_per_jugador_[i] == 0.0f) { // Only active, alive players
if (jugador_actiu && itocado_per_jugador_[i] == 0.0F) { // Only active, alive players
naus_[i].processar_input(delta_time, i);
naus_[i].actualitzar(delta_time);
}
@@ -553,8 +553,8 @@ void EscenaJoc::dibuixar() {
// Calcular centre de l'àrea de joc usant constants
const SDL_FRect& play_area = Defaults::Zones::PLAYAREA;
float centre_x = play_area.x + play_area.w / 2.0f;
float centre_y = play_area.y + play_area.h / 2.0f;
float centre_x = play_area.x + play_area.w / 2.0F;
float centre_y = play_area.y + play_area.h / 2.0F;
text_.render_centered(game_over_text, {centre_x, centre_y}, escala, spacing);
@@ -570,7 +570,7 @@ void EscenaJoc::dibuixar() {
// Calcular progrés de cada animació independent
float timer = stage_manager_->get_timer_transicio();
float total_time = Defaults::Game::INIT_HUD_DURATION;
float global_progress = 1.0f - (timer / total_time);
float global_progress = 1.0F - (timer / total_time);
// [NEW] Calcular progress independiente para cada elemento
float rect_progress = calcular_progress_rango(
@@ -594,7 +594,7 @@ void EscenaJoc::dibuixar() {
Defaults::Game::INIT_HUD_SHIP2_RATIO_END);
// Dibuixar elements animats
if (rect_progress > 0.0f) {
if (rect_progress > 0.0F) {
// [NOU] Reproduir so quan comença l'animació del rectangle
if (!init_hud_rect_sound_played_) {
Audio::get()->playSound(Defaults::Sound::INIT_HUD, Audio::Group::GAME);
@@ -604,16 +604,16 @@ void EscenaJoc::dibuixar() {
dibuixar_marges_animat(rect_progress);
}
if (score_progress > 0.0f) {
if (score_progress > 0.0F) {
dibuixar_marcador_animat(score_progress);
}
// [MODIFICAT] Dibuixar naus amb progress independent
if (ship1_progress > 0.0f && config_partida_.jugador1_actiu && !naus_[0].esta_tocada()) {
if (ship1_progress > 0.0F && config_partida_.jugador1_actiu && !naus_[0].esta_tocada()) {
naus_[0].dibuixar();
}
if (ship2_progress > 0.0f && config_partida_.jugador2_actiu && !naus_[1].esta_tocada()) {
if (ship2_progress > 0.0F && config_partida_.jugador2_actiu && !naus_[1].esta_tocada()) {
naus_[1].dibuixar();
}
@@ -625,7 +625,7 @@ void EscenaJoc::dibuixar() {
// [NEW] Draw both ships if active and alive
for (uint8_t i = 0; i < 2; i++) {
bool jugador_actiu = (i == 0) ? config_partida_.jugador1_actiu : config_partida_.jugador2_actiu;
if (jugador_actiu && itocado_per_jugador_[i] == 0.0f) {
if (jugador_actiu && itocado_per_jugador_[i] == 0.0F) {
naus_[i].dibuixar();
}
}
@@ -650,7 +650,7 @@ void EscenaJoc::dibuixar() {
// [EXISTING] Normal rendering - active ships
for (uint8_t i = 0; i < 2; i++) {
bool jugador_actiu = (i == 0) ? config_partida_.jugador1_actiu : config_partida_.jugador2_actiu;
if (jugador_actiu && itocado_per_jugador_[i] == 0.0f) {
if (jugador_actiu && itocado_per_jugador_[i] == 0.0F) {
naus_[i].dibuixar();
}
}
@@ -673,7 +673,7 @@ void EscenaJoc::dibuixar() {
// [NEW] Draw both ships if active and alive
for (uint8_t i = 0; i < 2; i++) {
bool jugador_actiu = (i == 0) ? config_partida_.jugador1_actiu : config_partida_.jugador2_actiu;
if (jugador_actiu && itocado_per_jugador_[i] == 0.0f) {
if (jugador_actiu && itocado_per_jugador_[i] == 0.0F) {
naus_[i].dibuixar();
}
}
@@ -700,7 +700,7 @@ void EscenaJoc::tocado(uint8_t player_id) {
// Phase 2: Animation (0 < itocado_ < 3.0s) - debris animation
// Phase 3: Respawn or game over (itocado_ >= 3.0s) - handled in actualitzar()
if (itocado_per_jugador_[player_id] == 0.0f) {
if (itocado_per_jugador_[player_id] == 0.0F) {
// *** PHASE 1: TRIGGER DEATH ***
// Mark ship as dead (stops rendering and input)
@@ -711,23 +711,23 @@ void EscenaJoc::tocado(uint8_t player_id) {
float ship_angle = naus_[player_id].get_angle();
Punt vel_nau = naus_[player_id].get_velocitat_vector();
// Reduir a 80% la velocitat heretada per la nau (més realista)
Punt vel_nau_80 = {vel_nau.x * 0.8f, vel_nau.y * 0.8f};
Punt vel_nau_80 = {vel_nau.x * 0.8F, vel_nau.y * 0.8F};
debris_manager_.explotar(
naus_[player_id].get_forma(), // Ship shape (3 lines)
ship_pos, // Center position
ship_angle, // Ship orientation
1.0f, // Normal scale
1.0F, // Normal scale
Defaults::Physics::Debris::VELOCITAT_BASE, // 80 px/s
naus_[player_id].get_brightness(), // Heredar brightness
vel_nau_80, // Heredar 80% velocitat
0.0f, // Nave: trayectorias rectas (sin drotacio)
0.0f, // Sin herencia visual (rotación aleatoria)
0.0F, // Nave: trayectorias rectas (sin drotacio)
0.0F, // Sin herencia visual (rotación aleatoria)
Defaults::Sound::EXPLOSION2 // Sonido alternativo para la explosión
);
// Start death timer (non-zero to avoid re-triggering)
itocado_per_jugador_[player_id] = 0.001f;
itocado_per_jugador_[player_id] = 0.001F;
}
// Phase 2 is automatic (debris updates in actualitzar())
// Phase 3 is handled in actualitzar() when itocado_per_jugador_ >= DEATH_DURATION
@@ -755,13 +755,13 @@ void EscenaJoc::dibuixar_marcador() {
std::string text = construir_marcador();
// Paràmetres de renderització
const float escala = 0.85f;
const float spacing = 0.0f;
const float escala = 0.85F;
const float spacing = 0.0F;
// Calcular centre de la zona del marcador
const SDL_FRect& scoreboard = Defaults::Zones::SCOREBOARD;
float centre_x = scoreboard.w / 2.0f;
float centre_y = scoreboard.y + scoreboard.h / 2.0f;
float centre_x = scoreboard.w / 2.0F;
float centre_y = scoreboard.y + scoreboard.h / 2.0F;
// Renderitzar centrat
text_.render_centered(text, {centre_x, centre_y}, escala, spacing);
@@ -784,12 +784,12 @@ void EscenaJoc::dibuixar_marges_animat(float progress) const {
int cx = (x1 + x2) / 2;
// Dividir en 3 fases de 33% cada una
constexpr float PHASE_1_END = 0.33f;
constexpr float PHASE_2_END = 0.66f;
constexpr float PHASE_1_END = 0.33F;
constexpr float PHASE_2_END = 0.66F;
// --- FASE 1: Línies horitzontals superiors (0-33%) ---
if (eased_progress > 0.0f) {
float phase1_progress = std::min(eased_progress / PHASE_1_END, 1.0f);
if (eased_progress > 0.0F) {
float phase1_progress = std::min(eased_progress / PHASE_1_END, 1.0F);
// Línia esquerra: creix des del centre cap a l'esquerra
int x1_phase1 = static_cast<int>(cx - (cx - x1) * phase1_progress);
@@ -802,7 +802,7 @@ void EscenaJoc::dibuixar_marges_animat(float progress) const {
// --- FASE 2: Línies verticals laterals (33-66%) ---
if (eased_progress > PHASE_1_END) {
float phase2_progress = std::min((eased_progress - PHASE_1_END) / (PHASE_2_END - PHASE_1_END), 1.0f);
float phase2_progress = std::min((eased_progress - PHASE_1_END) / (PHASE_2_END - PHASE_1_END), 1.0F);
// Línia esquerra: creix des de dalt cap a baix
int y2_phase2 = static_cast<int>(y1 + (y2 - y1) * phase2_progress);
@@ -814,7 +814,7 @@ void EscenaJoc::dibuixar_marges_animat(float progress) const {
// --- FASE 3: Línies horitzontals inferiors (66-100%) ---
if (eased_progress > PHASE_2_END) {
float phase3_progress = (eased_progress - PHASE_2_END) / (1.0f - PHASE_2_END);
float phase3_progress = (eased_progress - PHASE_2_END) / (1.0F - PHASE_2_END);
// Línia esquerra: creix des de l'esquerra cap al centre
int x_left_phase3 = static_cast<int>(x1 + (cx - x1) * phase3_progress);
@@ -836,13 +836,13 @@ void EscenaJoc::dibuixar_marcador_animat(float progress) {
std::string text = construir_marcador();
// Paràmetres
const float escala = 0.85f;
const float spacing = 0.0f;
const float escala = 0.85F;
const float spacing = 0.0F;
// Calcular centre de la zona del marcador
const SDL_FRect& scoreboard = Defaults::Zones::SCOREBOARD;
float centre_x = scoreboard.w / 2.0f;
float centre_y_final = scoreboard.y + scoreboard.h / 2.0f;
float centre_x = scoreboard.w / 2.0F;
float centre_y_final = scoreboard.y + scoreboard.h / 2.0F;
// Posició Y inicial (offscreen, sota de la pantalla)
float centre_y_inicial = static_cast<float>(Defaults::Game::HEIGHT);
@@ -869,7 +869,7 @@ Punt EscenaJoc::calcular_posicio_nau_init_hud(float progress, uint8_t player_id)
float y_final = spawn_final.y;
// Y inicial: offscreen, 50px sota la zona de joc
float y_inicial = zona.y + zona.h + 50.0f;
float y_inicial = zona.y + zona.h + 50.0F;
// X no canvia (destí segons player_id)
// Y interpola amb easing
@@ -888,15 +888,15 @@ float EscenaJoc::calcular_progress_rango(float global_progress, float ratio_init
// Validación de parámetros (evita división por cero)
if (ratio_init >= ratio_end) {
return (global_progress >= ratio_end) ? 1.0f : 0.0f;
return (global_progress >= ratio_end) ? 1.0F : 0.0F;
}
if (global_progress < ratio_init) {
return 0.0f;
return 0.0F;
}
if (global_progress > ratio_end) {
return 1.0f;
return 1.0F;
}
// Normalizar rango [INIT, END] a [0.0, 1.0]
@@ -946,11 +946,11 @@ void EscenaJoc::detectar_col·lisions_bales_enemics() {
// Constants amplificades per hitbox més generós (115%)
constexpr float RADI_BALA = Defaults::Entities::BULLET_RADIUS;
constexpr float RADI_ENEMIC = Defaults::Entities::ENEMY_RADIUS;
constexpr float SUMA_RADIS = (RADI_BALA + RADI_ENEMIC) * 1.15f; // 28.75 px
constexpr float SUMA_RADIS = (RADI_BALA + RADI_ENEMIC) * 1.15F; // 28.75 px
constexpr float SUMA_RADIS_QUADRAT = SUMA_RADIS * SUMA_RADIS; // 826.56
// Velocitat d'explosió reduïda per efecte suau
constexpr float VELOCITAT_EXPLOSIO = 80.0f; // px/s (en lloc de 80.0f per defecte)
constexpr float VELOCITAT_EXPLOSIO = 80.0F; // px/s (en lloc de 80.0f per defecte)
// Iterar per totes les bales actives
for (auto& bala : bales_) {
@@ -1006,13 +1006,13 @@ void EscenaJoc::detectar_col·lisions_bales_enemics() {
debris_manager_.explotar(
enemic.get_forma(), // Forma vectorial del pentàgon
pos_enemic, // Posició central
0.0f, // Angle (enemic té rotació interna)
1.0f, // Escala normal
0.0F, // Angle (enemic té rotació interna)
1.0F, // Escala normal
VELOCITAT_EXPLOSIO, // 50 px/s (explosió suau)
enemic.get_brightness(), // Heredar brightness
vel_enemic, // Heredar velocitat
enemic.get_drotacio(), // Heredar velocitat angular (trayectorias curvas)
0.0f // Sin herencia visual (rotación aleatoria)
0.0F // Sin herencia visual (rotación aleatoria)
);
// 3. Desactivar bala
@@ -1036,7 +1036,7 @@ void EscenaJoc::detectar_col·lisio_naus_enemics() {
// Check collision for BOTH players
for (uint8_t i = 0; i < 2; i++) {
// Skip collisions if player is dead or invulnerable
if (itocado_per_jugador_[i] > 0.0f) continue;
if (itocado_per_jugador_[i] > 0.0F) continue;
if (!naus_[i].esta_viva()) continue;
if (naus_[i].es_invulnerable()) continue;
@@ -1089,7 +1089,7 @@ void EscenaJoc::detectar_col·lisions_bales_jugadors() {
}
// Skip bullets in grace period (prevents instant self-collision)
if (bala.get_grace_timer() > 0.0f) {
if (bala.get_grace_timer() > 0.0F) {
continue;
}
@@ -1099,7 +1099,7 @@ void EscenaJoc::detectar_col·lisions_bales_jugadors() {
// Check collision with BOTH players
for (uint8_t player_id = 0; player_id < 2; player_id++) {
// Skip if player is dead, invulnerable, or inactive
if (itocado_per_jugador_[player_id] > 0.0f) continue;
if (itocado_per_jugador_[player_id] > 0.0F) continue;
if (!naus_[player_id].esta_viva()) continue;
if (naus_[player_id].es_invulnerable()) continue;
@@ -1147,8 +1147,8 @@ void EscenaJoc::detectar_col·lisions_bales_jugadors() {
// [NEW] Stage system helper methods
void EscenaJoc::dibuixar_missatge_stage(const std::string& missatge) {
constexpr float escala_base = 1.0f;
constexpr float spacing = 2.0f;
constexpr float escala_base = 1.0F;
constexpr float spacing = 2.0F;
const SDL_FRect& play_area = Defaults::Zones::PLAYAREA;
const float max_width = play_area.w * Defaults::Game::STAGE_MESSAGE_MAX_WIDTH_RATIO;
@@ -1168,16 +1168,16 @@ void EscenaJoc::dibuixar_missatge_stage(const std::string& missatge) {
// Calculate progress from timer (0.0 at start → 1.0 at end)
float remaining_time = stage_manager_->get_timer_transicio();
float progress = 1.0f - (remaining_time / total_time);
float progress = 1.0F - (remaining_time / total_time);
// Determine how many characters to show
size_t visible_chars;
if (typing_ratio > 0.0f && progress < typing_ratio) {
if (typing_ratio > 0.0F && progress < typing_ratio) {
// Typewriter phase: show partial text
float typing_progress = progress / typing_ratio; // Normalize to 0.0-1.0
visible_chars = static_cast<size_t>(missatge.length() * typing_progress);
if (visible_chars == 0 && progress > 0.0f) {
if (visible_chars == 0 && progress > 0.0F) {
visible_chars = 1; // Show at least 1 character after first frame
}
} else {
@@ -1203,8 +1203,8 @@ void EscenaJoc::dibuixar_missatge_stage(const std::string& missatge) {
float text_height = text_.get_text_height(escala);
// Calculate position as if FULL text was there (for fixed position typewriter)
float x = play_area.x + (play_area.w - full_text_width) / 2.0f;
float y = play_area.y + (play_area.h * Defaults::Game::STAGE_MESSAGE_Y_RATIO) - (text_height / 2.0f);
float x = play_area.x + (play_area.w - full_text_width) / 2.0F;
float y = play_area.y + (play_area.h * Defaults::Game::STAGE_MESSAGE_Y_RATIO) - (text_height / 2.0F);
// Render only the partial message (typewriter effect)
Punt pos = {x, y};
@@ -1221,7 +1221,7 @@ Punt EscenaJoc::obtenir_punt_spawn(uint8_t player_id) const {
float x_ratio;
if (config_partida_.es_un_jugador()) {
// Un sol jugador: spawn al centre (50%)
x_ratio = 0.5f;
x_ratio = 0.5F;
} else {
// Dos jugadors: spawn a posicions separades
x_ratio = (player_id == 0)
@@ -1236,15 +1236,15 @@ Punt EscenaJoc::obtenir_punt_spawn(uint8_t player_id) const {
void EscenaJoc::disparar_bala(uint8_t player_id) {
// Verificar que el jugador está vivo
if (itocado_per_jugador_[player_id] > 0.0f) return;
if (itocado_per_jugador_[player_id] > 0.0F) return;
if (!naus_[player_id].esta_viva()) return;
// Calcular posición en la punta de la nave
const Punt& ship_centre = naus_[player_id].get_centre();
float ship_angle = naus_[player_id].get_angle();
constexpr float LOCAL_TIP_X = 0.0f;
constexpr float LOCAL_TIP_Y = -12.0f;
constexpr float LOCAL_TIP_X = 0.0F;
constexpr float LOCAL_TIP_Y = -12.0F;
float cos_a = std::cos(ship_angle);
float sin_a = std::sin(ship_angle);
float tip_x = LOCAL_TIP_X * cos_a - LOCAL_TIP_Y * sin_a + ship_centre.x;
@@ -1273,7 +1273,7 @@ void EscenaJoc::check_and_apply_continue_timeout() {
void EscenaJoc::actualitzar_continue(float delta_time) {
continue_tick_timer_ -= delta_time;
if (continue_tick_timer_ <= 0.0f) {
if (continue_tick_timer_ <= 0.0F) {
continue_counter_--;
continue_tick_timer_ = Defaults::Game::CONTINUE_TICK_DURATION;
@@ -1314,7 +1314,7 @@ void EscenaJoc::processar_input_continue() {
// Reset score and lives (KEEP level and enemies!)
puntuacio_per_jugador_[player_to_revive] = 0;
vides_per_jugador_[player_to_revive] = Defaults::Game::STARTING_LIVES;
itocado_per_jugador_[player_to_revive] = 0.0f;
itocado_per_jugador_[player_to_revive] = 0.0F;
// Activate player if not already
if (player_to_revive == 0) {
@@ -1332,7 +1332,7 @@ void EscenaJoc::processar_input_continue() {
uint8_t other_player = 1;
puntuacio_per_jugador_[other_player] = 0;
vides_per_jugador_[other_player] = Defaults::Game::STARTING_LIVES;
itocado_per_jugador_[other_player] = 0.0f;
itocado_per_jugador_[other_player] = 0.0F;
config_partida_.jugador2_actiu = true;
Punt spawn_pos2 = obtenir_punt_spawn(other_player);
naus_[other_player].inicialitzar(&spawn_pos2, true);
@@ -1341,7 +1341,7 @@ void EscenaJoc::processar_input_continue() {
// Resume game
estat_game_over_ = EstatGameOver::NONE;
continue_counter_ = 0;
continue_tick_timer_ = 0.0f;
continue_tick_timer_ = 0.0F;
// Play continue confirmation sound
Audio::get()->playSound(Defaults::Sound::START, Audio::Group::GAME);
@@ -1373,14 +1373,14 @@ void EscenaJoc::processar_input_continue() {
void EscenaJoc::dibuixar_continue() {
const SDL_FRect& play_area = Defaults::Zones::PLAYAREA;
constexpr float spacing = 4.0f;
constexpr float spacing = 4.0F;
// "CONTINUE" text (using constants)
const std::string continue_text = "CONTINUE";
float escala_continue = Defaults::Game::ContinueScreen::CONTINUE_TEXT_SCALE;
float y_ratio_continue = Defaults::Game::ContinueScreen::CONTINUE_TEXT_Y_RATIO;
float centre_x = play_area.x + play_area.w / 2.0f;
float centre_x = play_area.x + play_area.w / 2.0F;
float centre_y_continue = play_area.y + play_area.h * y_ratio_continue;
text_.render_centered(continue_text, {centre_x, centre_y_continue}, escala_continue, spacing);
@@ -1417,7 +1417,7 @@ void EscenaJoc::unir_jugador(uint8_t player_id) {
// Reset stats
vides_per_jugador_[player_id] = Defaults::Game::STARTING_LIVES;
puntuacio_per_jugador_[player_id] = 0;
itocado_per_jugador_[player_id] = 0.0f;
itocado_per_jugador_[player_id] = 0.0F;
// Spawn with invulnerability
Punt spawn_pos = obtenir_punt_spawn(player_id);

View File

@@ -26,19 +26,19 @@ using Opcio = ContextEscenes::Opcio;
// en funció del progrés global (efecte seqüencial)
static float calcular_progress_letra(size_t letra_index, size_t num_letras, float global_progress, float threshold) {
if (num_letras == 0)
return 1.0f;
return 1.0F;
// Calcular temps per lletra
float duration_per_letra = 1.0f / static_cast<float>(num_letras);
float duration_per_letra = 1.0F / static_cast<float>(num_letras);
float step = threshold * duration_per_letra;
float start = static_cast<float>(letra_index) * step;
float end = start + duration_per_letra;
// Interpolar progrés
if (global_progress < start) {
return 0.0f; // Encara no ha començat
return 0.0F; // Encara no ha començat
} else if (global_progress >= end) {
return 1.0f; // Completament apareguda
return 1.0F; // Completament apareguda
} else {
return (global_progress - start) / (end - start);
}
@@ -48,10 +48,10 @@ EscenaLogo::EscenaLogo(SDLManager& sdl, ContextEscenes& context)
: sdl_(sdl),
context_(context),
estat_actual_(EstatAnimacio::PRE_ANIMATION),
temps_estat_actual_(0.0f),
temps_estat_actual_(0.0F),
debris_manager_(std::make_unique<Effects::DebrisManager>(sdl.obte_renderer())),
lletra_explosio_index_(0),
temps_des_ultima_explosio_(0.0f) {
temps_des_ultima_explosio_(0.0F) {
std::cout << "Escena Logo: Inicialitzant...\n";
// Consumir opcions (LOGO no processa opcions actualment)
@@ -75,12 +75,12 @@ void EscenaLogo::executar() {
while (GestorEscenes::actual == Escena::LOGO) {
// Calcular delta_time real
Uint64 current_time = SDL_GetTicks();
float delta_time = (current_time - last_time) / 1000.0f;
float delta_time = (current_time - last_time) / 1000.0F;
last_time = current_time;
// Limitar delta_time per evitar grans salts
if (delta_time > 0.05f) {
delta_time = 0.05f;
if (delta_time > 0.05F) {
delta_time = 0.05F;
}
// Actualitzar comptador de FPS
@@ -140,7 +140,7 @@ void EscenaLogo::inicialitzar_lletres() {
"logo/letra_s.shp"};
// Pas 1: Carregar totes les formes i calcular amplades
float ancho_total = 0.0f;
float ancho_total = 0.0F;
for (const auto& fitxer : fitxers) {
auto forma = ShapeLoader::load(fitxer);
@@ -168,7 +168,7 @@ void EscenaLogo::inicialitzar_lletres() {
float offset_centre = (forma->get_centre().x - min_x) * ESCALA_FINAL;
lletres_.push_back({forma,
{0.0f, 0.0f}, // Posició es calcularà després
{0.0F, 0.0F}, // Posició es calcularà després
ancho,
offset_centre});
@@ -179,11 +179,11 @@ void EscenaLogo::inicialitzar_lletres() {
ancho_total += ESPAI_ENTRE_LLETRES * (lletres_.size() - 1);
// Pas 3: Calcular posició inicial (centrat horitzontal)
constexpr float PANTALLA_ANCHO = 640.0f;
constexpr float PANTALLA_ALTO = 480.0f;
constexpr float PANTALLA_ANCHO = 640.0F;
constexpr float PANTALLA_ALTO = 480.0F;
float x_inicial = (PANTALLA_ANCHO - ancho_total) / 2.0f;
float y_centre = PANTALLA_ALTO / 2.0f;
float x_inicial = (PANTALLA_ANCHO - ancho_total) / 2.0F;
float y_centre = PANTALLA_ALTO / 2.0F;
// Pas 4: Assignar posicions a cada lletra
float x_actual = x_inicial;
@@ -205,12 +205,12 @@ void EscenaLogo::inicialitzar_lletres() {
void EscenaLogo::canviar_estat(EstatAnimacio nou_estat) {
estat_actual_ = nou_estat;
temps_estat_actual_ = 0.0f; // Reset temps
temps_estat_actual_ = 0.0F; // Reset temps
// Inicialitzar estat d'explosió
if (nou_estat == EstatAnimacio::EXPLOSION) {
lletra_explosio_index_ = 0;
temps_des_ultima_explosio_ = 0.0f;
temps_des_ultima_explosio_ = 0.0F;
// Generar ordre aleatori d'explosions
ordre_explosio_.clear();
@@ -246,18 +246,18 @@ void EscenaLogo::actualitzar_explosions(float delta_time) {
debris_manager_->explotar(
lletra.forma, // Forma a explotar
lletra.posicio, // Posició
0.0f, // Angle (sense rotació)
0.0F, // Angle (sense rotació)
ESCALA_FINAL, // Escala (lletres a escala final)
VELOCITAT_EXPLOSIO, // Velocitat base
1.0f, // Brightness màxim (per defecte)
{0.0f, 0.0f} // Sense velocitat (per defecte)
1.0F, // Brightness màxim (per defecte)
{0.0F, 0.0F} // Sense velocitat (per defecte)
);
std::cout << "[EscenaLogo] Explota lletra " << lletra_explosio_index_ << "\n";
// Passar a la següent lletra
lletra_explosio_index_++;
temps_des_ultima_explosio_ = 0.0f;
temps_des_ultima_explosio_ = 0.0F;
} else {
// Totes les lletres han explotat, transició a POST_EXPLOSION
canviar_estat(EstatAnimacio::POST_EXPLOSION);
@@ -277,7 +277,7 @@ void EscenaLogo::actualitzar(float delta_time) {
case EstatAnimacio::ANIMATION: {
// Reproduir so per cada lletra quan comença a aparèixer
float global_progress = std::min(temps_estat_actual_ / DURACIO_ZOOM, 1.0f);
float global_progress = std::min(temps_estat_actual_ / DURACIO_ZOOM, 1.0F);
for (size_t i = 0; i < lletres_.size() && i < so_reproduit_.size(); i++) {
if (!so_reproduit_[i]) {
@@ -288,7 +288,7 @@ void EscenaLogo::actualitzar(float delta_time) {
THRESHOLD_LETRA);
// Reproduir so quan la lletra comença a aparèixer (progress > 0)
if (letra_progress > 0.0f) {
if (letra_progress > 0.0F) {
Audio::get()->playSound(Defaults::Sound::LOGO, Audio::Group::GAME);
so_reproduit_[i] = true;
}
@@ -345,8 +345,8 @@ void EscenaLogo::dibuixar() {
estat_actual_ == EstatAnimacio::POST_ANIMATION) {
float global_progress =
(estat_actual_ == EstatAnimacio::ANIMATION)
? std::min(temps_estat_actual_ / DURACIO_ZOOM, 1.0f)
: 1.0f; // POST: mantenir al 100%
? std::min(temps_estat_actual_ / DURACIO_ZOOM, 1.0F)
: 1.0F; // POST: mantenir al 100%
const Punt ORIGEN_ZOOM = {ORIGEN_ZOOM_X, ORIGEN_ZOOM_Y};
@@ -359,7 +359,7 @@ void EscenaLogo::dibuixar() {
global_progress,
THRESHOLD_LETRA);
if (letra_progress <= 0.0f) {
if (letra_progress <= 0.0F) {
continue;
}
@@ -370,7 +370,7 @@ void EscenaLogo::dibuixar() {
ORIGEN_ZOOM.y + (lletra.posicio.y - ORIGEN_ZOOM.y) * letra_progress;
float t = letra_progress;
float ease_factor = 1.0f - (1.0f - t) * (1.0f - t);
float ease_factor = 1.0F - (1.0F - t) * (1.0F - t);
float escala_actual =
ESCALA_INICIAL + (ESCALA_FINAL - ESCALA_INICIAL) * ease_factor;
@@ -378,10 +378,10 @@ void EscenaLogo::dibuixar() {
sdl_.obte_renderer(),
lletra.forma,
pos_actual,
0.0f,
0.0F,
escala_actual,
true,
1.0f);
1.0F);
}
}
@@ -402,10 +402,10 @@ void EscenaLogo::dibuixar() {
sdl_.obte_renderer(),
lletra.forma,
lletra.posicio,
0.0f,
0.0F,
ESCALA_FINAL,
true,
1.0f);
1.0F);
}
}
}

View File

@@ -62,20 +62,20 @@ class EscenaLogo {
std::array<bool, 9> so_reproduit_; // Track si cada lletra ja ha reproduit el so
// Constants d'animació
static constexpr float DURACIO_PRE = 1.5f; // Duració PRE_ANIMATION (pantalla negra)
static constexpr float DURACIO_ZOOM = 4.0f; // Duració del zoom (segons)
static constexpr float DURACIO_POST_ANIMATION = 3.0f; // Duració POST_ANIMATION (logo complet)
static constexpr float DURACIO_POST_EXPLOSION = 3.0f; // Duració POST_EXPLOSION (espera final)
static constexpr float DELAY_ENTRE_EXPLOSIONS = 0.1f; // Temps entre explosions de lletres
static constexpr float VELOCITAT_EXPLOSIO = 240.0f; // Velocitat base fragments (px/s)
static constexpr float ESCALA_INICIAL = 0.1f; // Escala inicial (10%)
static constexpr float ESCALA_FINAL = 0.8f; // Escala final (80%)
static constexpr float ESPAI_ENTRE_LLETRES = 10.0f; // Espaiat entre lletres
static constexpr float DURACIO_PRE = 1.5F; // Duració PRE_ANIMATION (pantalla negra)
static constexpr float DURACIO_ZOOM = 4.0F; // Duració del zoom (segons)
static constexpr float DURACIO_POST_ANIMATION = 3.0F; // Duració POST_ANIMATION (logo complet)
static constexpr float DURACIO_POST_EXPLOSION = 3.0F; // Duració POST_EXPLOSION (espera final)
static constexpr float DELAY_ENTRE_EXPLOSIONS = 0.1F; // Temps entre explosions de lletres
static constexpr float VELOCITAT_EXPLOSIO = 240.0F; // Velocitat base fragments (px/s)
static constexpr float ESCALA_INICIAL = 0.1F; // Escala inicial (10%)
static constexpr float ESCALA_FINAL = 0.8F; // Escala final (80%)
static constexpr float ESPAI_ENTRE_LLETRES = 10.0F; // Espaiat entre lletres
// Constants d'animació seqüencial
static constexpr float THRESHOLD_LETRA = 0.6f; // Umbral per activar següent lletra (0.0-1.0)
static constexpr float ORIGEN_ZOOM_X = Defaults::Game::WIDTH * 0.5f; // Punt inicial X del zoom
static constexpr float ORIGEN_ZOOM_Y = Defaults::Game::HEIGHT * 0.4f; // Punt inicial Y del zoom
static constexpr float THRESHOLD_LETRA = 0.6F; // Umbral per activar següent lletra (0.0-1.0)
static constexpr float ORIGEN_ZOOM_X = Defaults::Game::WIDTH * 0.5F; // Punt inicial X del zoom
static constexpr float ORIGEN_ZOOM_Y = Defaults::Game::HEIGHT * 0.4F; // Punt inicial Y del zoom
// Mètodes privats
void inicialitzar_lletres();

View File

@@ -27,11 +27,11 @@ EscenaTitol::EscenaTitol(SDLManager& sdl, ContextEscenes& context)
context_(context),
text_(sdl.obte_renderer()),
estat_actual_(EstatTitol::STARFIELD_FADE_IN),
temps_acumulat_(0.0f),
temps_animacio_(0.0f),
temps_estat_main_(0.0f),
temps_acumulat_(0.0F),
temps_animacio_(0.0F),
temps_estat_main_(0.0F),
animacio_activa_(false),
factor_lerp_(0.0f) {
factor_lerp_(0.0F) {
std::cout << "Escena Titol: Inicialitzant...\n";
// Inicialitzar configuració de partida (cap jugador actiu per defecte)
@@ -45,13 +45,13 @@ EscenaTitol::EscenaTitol(SDLManager& sdl, ContextEscenes& context)
if (opcio == Opcio::JUMP_TO_TITLE_MAIN) {
std::cout << "Escena Titol: Opció JUMP_TO_TITLE_MAIN activada\n";
estat_actual_ = EstatTitol::MAIN;
temps_estat_main_ = 0.0f;
temps_estat_main_ = 0.0F;
}
// Crear starfield de fons
Punt centre_pantalla{
Defaults::Game::WIDTH / 2.0f,
Defaults::Game::HEIGHT / 2.0f};
Defaults::Game::WIDTH / 2.0F,
Defaults::Game::HEIGHT / 2.0F};
SDL_FRect area_completa{
0,
@@ -72,7 +72,7 @@ EscenaTitol::EscenaTitol(SDLManager& sdl, ContextEscenes& context)
starfield_->set_brightness(BRIGHTNESS_STARFIELD);
} else {
// Flux normal: comença amb brightness 0.0 per fade-in
starfield_->set_brightness(0.0f);
starfield_->set_brightness(0.0F);
}
// Inicialitzar animador de naus 3D
@@ -113,7 +113,7 @@ void EscenaTitol::inicialitzar_titol() {
"title/letra_i.shp"};
// Pas 1: Carregar formes i calcular amplades per "ORNI"
float ancho_total_orni = 0.0f;
float ancho_total_orni = 0.0F;
for (const auto& fitxer : fitxers_orni) {
auto forma = ShapeLoader::load(fitxer);
@@ -145,7 +145,7 @@ void EscenaTitol::inicialitzar_titol() {
float altura = altura_sin_escalar * Defaults::Title::Layout::LOGO_SCALE;
float offset_centre = (forma->get_centre().x - min_x) * Defaults::Title::Layout::LOGO_SCALE;
lletres_orni_.push_back({forma, {0.0f, 0.0f}, ancho, altura, offset_centre});
lletres_orni_.push_back({forma, {0.0F, 0.0F}, ancho, altura, offset_centre});
ancho_total_orni += ancho;
}
@@ -154,7 +154,7 @@ void EscenaTitol::inicialitzar_titol() {
ancho_total_orni += ESPAI_ENTRE_LLETRES * (lletres_orni_.size() - 1);
// Calcular posició inicial (centrat horitzontal) per "ORNI"
float x_inicial_orni = (Defaults::Game::WIDTH - ancho_total_orni) / 2.0f;
float x_inicial_orni = (Defaults::Game::WIDTH - ancho_total_orni) / 2.0F;
float x_actual = x_inicial_orni;
for (auto& lletra : lletres_orni_) {
@@ -168,7 +168,7 @@ void EscenaTitol::inicialitzar_titol() {
// === Calcular posició Y dinàmica per "ATTACK!" ===
// Totes les lletres ORNI tenen la mateixa altura, utilitzem la primera
float altura_orni = lletres_orni_.empty() ? 50.0f : lletres_orni_[0].altura;
float altura_orni = lletres_orni_.empty() ? 50.0F : lletres_orni_[0].altura;
float y_orni = Defaults::Game::HEIGHT * Defaults::Title::Layout::LOGO_POS;
float separacion_lineas = Defaults::Game::HEIGHT * Defaults::Title::Layout::LOGO_LINE_SPACING;
y_attack_dinamica_ = y_orni + altura_orni + separacion_lineas;
@@ -187,7 +187,7 @@ void EscenaTitol::inicialitzar_titol() {
"title/letra_exclamacion.shp"};
// Pas 1: Carregar formes i calcular amplades per "ATTACK!"
float ancho_total_attack = 0.0f;
float ancho_total_attack = 0.0F;
for (const auto& fitxer : fitxers_attack) {
auto forma = ShapeLoader::load(fitxer);
@@ -219,7 +219,7 @@ void EscenaTitol::inicialitzar_titol() {
float altura = altura_sin_escalar * Defaults::Title::Layout::LOGO_SCALE;
float offset_centre = (forma->get_centre().x - min_x) * Defaults::Title::Layout::LOGO_SCALE;
lletres_attack_.push_back({forma, {0.0f, 0.0f}, ancho, altura, offset_centre});
lletres_attack_.push_back({forma, {0.0F, 0.0F}, ancho, altura, offset_centre});
ancho_total_attack += ancho;
}
@@ -228,7 +228,7 @@ void EscenaTitol::inicialitzar_titol() {
ancho_total_attack += ESPAI_ENTRE_LLETRES * (lletres_attack_.size() - 1);
// Calcular posició inicial (centrat horitzontal) per "ATTACK!"
float x_inicial_attack = (Defaults::Game::WIDTH - ancho_total_attack) / 2.0f;
float x_inicial_attack = (Defaults::Game::WIDTH - ancho_total_attack) / 2.0F;
x_actual = x_inicial_attack;
for (auto& lletra : lletres_attack_) {
@@ -261,12 +261,12 @@ void EscenaTitol::executar() {
while (GestorEscenes::actual == Escena::TITOL) {
// Calcular delta_time real
Uint64 current_time = SDL_GetTicks();
float delta_time = (current_time - last_time) / 1000.0f;
float delta_time = (current_time - last_time) / 1000.0F;
last_time = current_time;
// Limitar delta_time per evitar grans salts
if (delta_time > 0.05f) {
delta_time = 0.05f;
if (delta_time > 0.05F) {
delta_time = 0.05F;
}
// Actualitzar comptador de FPS
@@ -339,7 +339,7 @@ void EscenaTitol::actualitzar(float delta_time) {
temps_acumulat_ += delta_time;
// Calcular progrés del fade (0.0 → 1.0)
float progress = std::min(1.0f, temps_acumulat_ / DURACIO_FADE_IN);
float progress = std::min(1.0F, temps_acumulat_ / DURACIO_FADE_IN);
// Lerp brightness de 0.0 a BRIGHTNESS_STARFIELD
float brightness_actual = progress * BRIGHTNESS_STARFIELD;
@@ -348,7 +348,7 @@ void EscenaTitol::actualitzar(float delta_time) {
// Transició a STARFIELD quan el fade es completa
if (temps_acumulat_ >= DURACIO_FADE_IN) {
estat_actual_ = EstatTitol::STARFIELD;
temps_acumulat_ = 0.0f; // Reset timer per al següent estat
temps_acumulat_ = 0.0F; // Reset timer per al següent estat
starfield_->set_brightness(BRIGHTNESS_STARFIELD); // Assegurar valor final
}
break;
@@ -358,9 +358,9 @@ void EscenaTitol::actualitzar(float delta_time) {
temps_acumulat_ += delta_time;
if (temps_acumulat_ >= DURACIO_INIT) {
estat_actual_ = EstatTitol::MAIN;
temps_estat_main_ = 0.0f; // Reset timer al entrar a MAIN
temps_estat_main_ = 0.0F; // Reset timer al entrar a MAIN
animacio_activa_ = false; // Comença estàtic
factor_lerp_ = 0.0f; // Sense animació encara
factor_lerp_ = 0.0F; // Sense animació encara
// Naus esperaran ENTRANCE_DELAY abans d'entrar (no iniciar aquí)
}
@@ -379,7 +379,7 @@ void EscenaTitol::actualitzar(float delta_time) {
// Fase 1: Estàtic (0-10s)
if (temps_estat_main_ < DELAY_INICI_ANIMACIO) {
factor_lerp_ = 0.0f;
factor_lerp_ = 0.0F;
animacio_activa_ = false;
}
// Fase 2: Lerp (10-12s)
@@ -390,7 +390,7 @@ void EscenaTitol::actualitzar(float delta_time) {
}
// Fase 3: Animació completa (12s+)
else {
factor_lerp_ = 1.0f;
factor_lerp_ = 1.0F;
animacio_activa_ = true;
}
@@ -430,7 +430,7 @@ void EscenaTitol::actualitzar(float delta_time) {
Audio::get()->playSound(Defaults::Sound::START, Audio::Group::GAME);
// Reiniciar el timer per allargar el temps de transició
temps_acumulat_ = 0.0f;
temps_acumulat_ = 0.0F;
std::cout << "[EscenaTitol] Segon jugador s'ha unit - so i timer reiniciats\n";
}
@@ -439,7 +439,7 @@ void EscenaTitol::actualitzar(float delta_time) {
if (temps_acumulat_ >= DURACIO_TRANSITION) {
// Transició a pantalla negra
estat_actual_ = EstatTitol::BLACK_SCREEN;
temps_acumulat_ = 0.0f;
temps_acumulat_ = 0.0F;
std::cout << "[EscenaTitol] Passant a BLACK_SCREEN\n";
}
break;
@@ -462,7 +462,7 @@ void EscenaTitol::actualitzar(float delta_time) {
// Saltar a MAIN
estat_actual_ = EstatTitol::MAIN;
starfield_->set_brightness(BRIGHTNESS_STARFIELD);
temps_estat_main_ = 0.0f;
temps_estat_main_ = 0.0F;
// Naus esperaran ENTRANCE_DELAY abans d'entrar (no iniciar aquí)
}
@@ -491,7 +491,7 @@ void EscenaTitol::actualitzar(float delta_time) {
context_.canviar_escena(Escena::JOC);
estat_actual_ = EstatTitol::PLAYER_JOIN_PHASE;
temps_acumulat_ = 0.0f;
temps_acumulat_ = 0.0F;
// Trigger animació de sortida NOMÉS per les naus que han premut START
if (ship_animator_) {
@@ -524,8 +524,8 @@ void EscenaTitol::actualitzar_animacio_logo(float delta_time) {
float frequency_y_actual = ORBIT_FREQUENCY_Y;
// Calcular offset orbital
float offset_x = amplitude_x_actual * std::sin(2.0f * Defaults::Math::PI * frequency_x_actual * temps_animacio_);
float offset_y = amplitude_y_actual * std::sin(2.0f * Defaults::Math::PI * frequency_y_actual * temps_animacio_ + ORBIT_PHASE_OFFSET);
float offset_x = amplitude_x_actual * std::sin(2.0F * Defaults::Math::PI * frequency_x_actual * temps_animacio_);
float offset_y = amplitude_y_actual * std::sin(2.0F * Defaults::Math::PI * frequency_y_actual * temps_animacio_ + ORBIT_PHASE_OFFSET);
// Aplicar offset a totes les lletres de "ORNI"
for (size_t i = 0; i < lletres_orni_.size(); ++i) {
@@ -567,7 +567,7 @@ void EscenaTitol::dibuixar() {
// === Calcular i renderitzar ombra (només si animació activa) ===
if (animacio_activa_) {
float temps_shadow = temps_animacio_ - SHADOW_DELAY;
if (temps_shadow < 0.0f) temps_shadow = 0.0f; // Evitar temps negatiu
if (temps_shadow < 0.0F) temps_shadow = 0.0F; // Evitar temps negatiu
// Usar amplituds i freqüències completes per l'ombra
float amplitude_x_shadow = ORBIT_AMPLITUDE_X;
@@ -576,8 +576,8 @@ void EscenaTitol::dibuixar() {
float frequency_y_shadow = ORBIT_FREQUENCY_Y;
// Calcular offset de l'ombra
float shadow_offset_x = amplitude_x_shadow * std::sin(2.0f * Defaults::Math::PI * frequency_x_shadow * temps_shadow) + SHADOW_OFFSET_X;
float shadow_offset_y = amplitude_y_shadow * std::sin(2.0f * Defaults::Math::PI * frequency_y_shadow * temps_shadow + ORBIT_PHASE_OFFSET) + SHADOW_OFFSET_Y;
float shadow_offset_x = amplitude_x_shadow * std::sin(2.0F * Defaults::Math::PI * frequency_x_shadow * temps_shadow) + SHADOW_OFFSET_X;
float shadow_offset_y = amplitude_y_shadow * std::sin(2.0F * Defaults::Math::PI * frequency_y_shadow * temps_shadow + ORBIT_PHASE_OFFSET) + SHADOW_OFFSET_Y;
// === RENDERITZAR OMBRA PRIMER (darrera del logo principal) ===
@@ -591,10 +591,10 @@ void EscenaTitol::dibuixar() {
sdl_.obte_renderer(),
lletres_orni_[i].forma,
pos_shadow,
0.0f,
0.0F,
Defaults::Title::Layout::LOGO_SCALE,
true,
1.0f, // progress = 1.0 (totalment visible)
1.0F, // progress = 1.0 (totalment visible)
SHADOW_BRIGHTNESS // brightness = 0.4 (brillantor reduïda)
);
}
@@ -609,10 +609,10 @@ void EscenaTitol::dibuixar() {
sdl_.obte_renderer(),
lletres_attack_[i].forma,
pos_shadow,
0.0f,
0.0F,
Defaults::Title::Layout::LOGO_SCALE,
true,
1.0f, // progress = 1.0 (totalment visible)
1.0F, // progress = 1.0 (totalment visible)
SHADOW_BRIGHTNESS);
}
}
@@ -625,10 +625,10 @@ void EscenaTitol::dibuixar() {
sdl_.obte_renderer(),
lletra.forma,
lletra.posicio,
0.0f,
0.0F,
Defaults::Title::Layout::LOGO_SCALE,
true,
1.0f // Brillantor completa
1.0F // Brillantor completa
);
}
@@ -638,10 +638,10 @@ void EscenaTitol::dibuixar() {
sdl_.obte_renderer(),
lletra.forma,
lletra.posicio,
0.0f,
0.0F,
Defaults::Title::Layout::LOGO_SCALE,
true,
1.0f // Brillantor completa
1.0F // Brillantor completa
);
}
@@ -654,15 +654,15 @@ void EscenaTitol::dibuixar() {
bool mostrar_text = true;
if (estat_actual_ == EstatTitol::PLAYER_JOIN_PHASE) {
// Parpelleig: sin oscil·la entre -1 i 1, volem ON quan > 0
float fase = temps_acumulat_ * BLINK_FREQUENCY * 2.0f * 3.14159f; // 2π × freq × temps
mostrar_text = (std::sin(fase) > 0.0f);
float fase = temps_acumulat_ * BLINK_FREQUENCY * 2.0F * 3.14159F; // 2π × freq × temps
mostrar_text = (std::sin(fase) > 0.0F);
}
if (mostrar_text) {
const std::string main_text = "PRESS START TO PLAY";
const float escala_main = Defaults::Title::Layout::PRESS_START_SCALE;
float centre_x = Defaults::Game::WIDTH / 2.0f;
float centre_x = Defaults::Game::WIDTH / 2.0F;
float centre_y = Defaults::Game::HEIGHT * Defaults::Title::Layout::PRESS_START_POS;
text_.render_centered(main_text, {centre_x, centre_y}, escala_main, spacing);
@@ -690,7 +690,7 @@ void EscenaTitol::dibuixar() {
float y_line2 = y_line1 + copy_height + line_spacing; // Línea 2 debajo de línea 1
// Renderitzar línees centrades
float centre_x = Defaults::Game::WIDTH / 2.0f;
float centre_x = Defaults::Game::WIDTH / 2.0F;
text_.render_centered(copyright_original, {centre_x, y_line1}, escala_copy, spacing);
text_.render_centered(copyright_port, {centre_x, y_line2}, escala_copy, spacing);

View File

@@ -75,31 +75,31 @@ class EscenaTitol {
float factor_lerp_; // Factor de lerp actual (0.0 → 1.0)
// Constants
static constexpr float BRIGHTNESS_STARFIELD = 1.2f; // Brightness del starfield (>1.0 = més brillant)
static constexpr float DURACIO_FADE_IN = 3.0f; // Duració del fade-in del starfield (1.5 segons)
static constexpr float DURACIO_INIT = 4.0f; // Duració de l'estat INIT (2 segons)
static constexpr float DURACIO_TRANSITION = 2.5f; // Duració de la transició (1.5 segons)
static constexpr float ESPAI_ENTRE_LLETRES = 10.0f; // Espai entre lletres
static constexpr float BLINK_FREQUENCY = 3.0f; // Freqüència de parpelleig (3 Hz)
static constexpr float DURACIO_BLACK_SCREEN = 2.0f; // Duració pantalla negra (2 segons)
static constexpr float BRIGHTNESS_STARFIELD = 1.2F; // Brightness del starfield (>1.0 = més brillant)
static constexpr float DURACIO_FADE_IN = 3.0F; // Duració del fade-in del starfield (1.5 segons)
static constexpr float DURACIO_INIT = 4.0F; // Duració de l'estat INIT (2 segons)
static constexpr float DURACIO_TRANSITION = 2.5F; // Duració de la transició (1.5 segons)
static constexpr float ESPAI_ENTRE_LLETRES = 10.0F; // Espai entre lletres
static constexpr float BLINK_FREQUENCY = 3.0F; // Freqüència de parpelleig (3 Hz)
static constexpr float DURACIO_BLACK_SCREEN = 2.0F; // Duració pantalla negra (2 segons)
static constexpr int MUSIC_FADE = 1500; // Duracio del fade de la musica del titol al començar a jugar
// Constants d'animació del logo
static constexpr float ORBIT_AMPLITUDE_X = 4.0f; // Amplitud oscil·lació horitzontal (píxels)
static constexpr float ORBIT_AMPLITUDE_Y = 3.0f; // Amplitud oscil·lació vertical (píxels)
static constexpr float ORBIT_FREQUENCY_X = 0.8f; // Velocitat oscil·lació horitzontal (Hz)
static constexpr float ORBIT_FREQUENCY_Y = 1.2f; // Velocitat oscil·lació vertical (Hz)
static constexpr float ORBIT_PHASE_OFFSET = 1.57f; // Desfasament entre X i Y (90° per circular)
static constexpr float ORBIT_AMPLITUDE_X = 4.0F; // Amplitud oscil·lació horitzontal (píxels)
static constexpr float ORBIT_AMPLITUDE_Y = 3.0F; // Amplitud oscil·lació vertical (píxels)
static constexpr float ORBIT_FREQUENCY_X = 0.8F; // Velocitat oscil·lació horitzontal (Hz)
static constexpr float ORBIT_FREQUENCY_Y = 1.2F; // Velocitat oscil·lació vertical (Hz)
static constexpr float ORBIT_PHASE_OFFSET = 1.57F; // Desfasament entre X i Y (90° per circular)
// Constants d'ombra del logo
static constexpr float SHADOW_DELAY = 0.5f; // Retard temporal de l'ombra (segons)
static constexpr float SHADOW_BRIGHTNESS = 0.4f; // Multiplicador de brillantor de l'ombra (0.0-1.0)
static constexpr float SHADOW_OFFSET_X = 2.0f; // Offset espacial X fix (píxels)
static constexpr float SHADOW_OFFSET_Y = 2.0f; // Offset espacial Y fix (píxels)
static constexpr float SHADOW_DELAY = 0.5F; // Retard temporal de l'ombra (segons)
static constexpr float SHADOW_BRIGHTNESS = 0.4F; // Multiplicador de brillantor de l'ombra (0.0-1.0)
static constexpr float SHADOW_OFFSET_X = 2.0F; // Offset espacial X fix (píxels)
static constexpr float SHADOW_OFFSET_Y = 2.0F; // Offset espacial Y fix (píxels)
// Temporització de l'arrencada de l'animació
static constexpr float DELAY_INICI_ANIMACIO = 10.0f; // 10s estàtic abans d'animar
static constexpr float DURACIO_LERP = 2.0f; // 2s per arribar a amplitud completa
static constexpr float DELAY_INICI_ANIMACIO = 10.0F; // 10s estàtic abans d'animar
static constexpr float DURACIO_LERP = 2.0F; // 2s per arribar a amplitud completa
// Mètodes privats
void actualitzar(float delta_time);