diff --git a/data/shapes/font/char_3.shp b/data/shapes/font/char_3.shp index 92bf575..2816f47 100644 --- a/data/shapes/font/char_3.shp +++ b/data/shapes/font/char_3.shp @@ -7,5 +7,5 @@ scale: 1.0 center: 10, 20 # Trazo continuo (barra superior + lateral derecho + barra media + lateral derecho + barra inferior) -polyline: 2,10 18,10 18,20 14,20 -polyline: 14,20 18,20 18,30 2,30 +polyline: 2,10 18,10 18,20 8,20 +polyline: 8,20 18,20 18,30 2,30 diff --git a/source/core/defaults.hpp b/source/core/defaults.hpp index d6ee86a..c0b6092 100644 --- a/source/core/defaults.hpp +++ b/source/core/defaults.hpp @@ -89,6 +89,9 @@ constexpr SDL_FRect SCOREBOARD = { static_cast(Game::WIDTH), // w = 640.0 SCOREBOARD_BOTTOM_H // h = 48.0 }; + +// Padding horizontal del marcador (per alinear zones esquerra/dreta amb PLAYAREA) +constexpr float SCOREBOARD_PADDING_H = 0.0f;//Game::WIDTH * 0.015f; } // namespace Zones // Objetos del juego diff --git a/source/game/escenes/escena_joc.cpp b/source/game/escenes/escena_joc.cpp index 157f5fa..da413d6 100644 --- a/source/game/escenes/escena_joc.cpp +++ b/source/game/escenes/escena_joc.cpp @@ -607,17 +607,8 @@ void EscenaJoc::dibuixar_marges() const { } void EscenaJoc::dibuixar_marcador() { - // [MODIFIED] Display current stage number from stage manager - uint8_t stage_num = stage_manager_->get_stage_actual(); - std::string stage_str = (stage_num < 10) ? "0" + std::to_string(stage_num) - : std::to_string(stage_num); - - // Format score with padding to 5 digits (e.g., 150 → "00150") - std::string score_str = std::to_string(puntuacio_total_); - score_str = std::string(5 - std::min(5, static_cast(score_str.length())), '0') + score_str; - - std::string text = "SCORE: " + score_str + " LIVES: " + std::to_string(num_vides_) + - " LEVEL: " + stage_str; + // Construir text del marcador + std::string text = construir_marcador(); // Paràmetres de renderització const float escala = 0.85f; @@ -703,21 +694,13 @@ void EscenaJoc::dibuixar_marcador_animat(float progress) { // Calcular progrés amb easing float eased_progress = Easing::ease_out_quad(progress); - // Posició final del marcador (normal) + // Construir text + std::string text = construir_marcador(); + + // Paràmetres const float escala = 0.85f; const float spacing = 0.0f; - // Formatar text igual que en dibuixar_marcador() normal - uint8_t stage_num = stage_manager_->get_stage_actual(); - std::string stage_str = (stage_num < 10) ? "0" + std::to_string(stage_num) - : std::to_string(stage_num); - - std::string score_str = std::to_string(puntuacio_total_); - score_str = std::string(5 - std::min(5, static_cast(score_str.length())), '0') + score_str; - - std::string text = "SCORE: " + score_str + " LIVES: " + std::to_string(num_vides_) + - " LEVEL: " + stage_str; - // Calcular dimensions float text_width = text_.get_text_width(text, escala, spacing); float text_height = text_.get_text_height(escala); @@ -763,6 +746,31 @@ Punt EscenaJoc::calcular_posicio_nau_init_hud(float progress) const { return {x_final, y_animada}; } +std::string EscenaJoc::construir_marcador() const { + // Puntuació P1 (5 dígits) + std::string score_p1 = std::to_string(puntuacio_total_); + score_p1 = std::string(6 - std::min(6, static_cast(score_p1.length())), '0') + score_p1; + + // Vides P1 (2 dígits) + std::string vides_p1 = (num_vides_ < 10) ? "0" + std::to_string(num_vides_) + : std::to_string(num_vides_); + + // Nivell (2 dígits) + uint8_t stage_num = stage_manager_->get_stage_actual(); + std::string stage_str = (stage_num < 10) ? "0" + std::to_string(stage_num) + : std::to_string(stage_num); + + // Puntuació P2 (sempre 00000 per ara) + std::string score_p2 = "000000"; + + // Vides P2 (sempre 03 per ara) + std::string vides_p2 = "03"; + + // Format: "12345 03 LEVEL 01 00000 03" + // Nota: dos espais entre seccions + return score_p1 + " " + vides_p1 + " LEVEL " + stage_str + " " + score_p2 + " " + vides_p2; +} + void EscenaJoc::detectar_col·lisions_bales_enemics() { // Constants amplificades per hitbox més generós (115%) constexpr float RADI_BALA = Defaults::Entities::BULLET_RADIUS; diff --git a/source/game/escenes/escena_joc.hpp b/source/game/escenes/escena_joc.hpp index 57179fc..f131a50 100644 --- a/source/game/escenes/escena_joc.hpp +++ b/source/game/escenes/escena_joc.hpp @@ -79,6 +79,9 @@ class EscenaJoc { void dibuixar_marges_animat(float progress) const; // Rectangle amb creixement uniforme void dibuixar_marcador_animat(float progress); // Marcador que puja des de baix Punt calcular_posicio_nau_init_hud(float progress) const; // Posició animada de la nau + + // [NEW] Funció helper del marcador + std::string construir_marcador() const; }; #endif // ESCENA_JOC_HPP