revisat el marcador

modificada la shape 03
This commit is contained in:
2025-12-10 11:05:15 +01:00
parent d0be5ea2d1
commit 9a5adcbcc5
4 changed files with 39 additions and 25 deletions

View File

@@ -89,6 +89,9 @@ constexpr SDL_FRect SCOREBOARD = {
static_cast<float>(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

View File

@@ -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<int>(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<int>(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<int>(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;

View File

@@ -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