From f3f0bfcd9acb80730087c6c604280074da710204 Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Tue, 16 Dec 2025 10:05:18 +0100 Subject: [PATCH] afegit so a init_hud --- source/game/escenes/escena_joc.cpp | 12 +++++++++++- source/game/escenes/escena_joc.hpp | 3 +++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/source/game/escenes/escena_joc.cpp b/source/game/escenes/escena_joc.cpp index e17f2cd..bba1a40 100644 --- a/source/game/escenes/escena_joc.cpp +++ b/source/game/escenes/escena_joc.cpp @@ -29,7 +29,8 @@ EscenaJoc::EscenaJoc(SDLManager& sdl, ContextEscenes& context) context_(context), debris_manager_(sdl.obte_renderer()), gestor_puntuacio_(sdl.obte_renderer()), - text_(sdl.obte_renderer()) { + text_(sdl.obte_renderer()), + init_hud_rect_sound_played_(false) { // Recuperar configuració de partida des del context config_partida_ = context_.get_config_partida(); @@ -198,6 +199,9 @@ void EscenaJoc::inicialitzar() { // [ELIMINAT] Iniciar música de joc (ara es gestiona en stage_manager) // La música s'inicia quan es transiciona de INIT_HUD a LEVEL_START // Audio::get()->playMusic("game.ogg"); + + // Reset flag de sons d'animació + init_hud_rect_sound_played_ = false; } void EscenaJoc::actualitzar(float delta_time) { @@ -520,6 +524,12 @@ void EscenaJoc::dibuixar() { // Dibuixar elements animats 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::LOGO, Audio::Group::GAME); + init_hud_rect_sound_played_ = true; + } + dibuixar_marges_animat(rect_progress); } diff --git a/source/game/escenes/escena_joc.hpp b/source/game/escenes/escena_joc.hpp index 2e01053..046cb7c 100644 --- a/source/game/escenes/escena_joc.hpp +++ b/source/game/escenes/escena_joc.hpp @@ -67,6 +67,9 @@ class EscenaJoc { std::unique_ptr stage_config_; std::unique_ptr stage_manager_; + // Control de sons d'animació INIT_HUD + bool init_hud_rect_sound_played_; // Flag para evitar repetir sonido del rectángulo + // Funcions privades void tocado(uint8_t player_id); void detectar_col·lisions_bales_enemics(); // Col·lisions bala-enemic