diff --git a/data/sounds/explosion.wav b/data/sounds/effects/explosion.wav similarity index 100% rename from data/sounds/explosion.wav rename to data/sounds/effects/explosion.wav diff --git a/data/sounds/laser_shoot.wav b/data/sounds/effects/laser_shoot.wav similarity index 100% rename from data/sounds/laser_shoot.wav rename to data/sounds/effects/laser_shoot.wav diff --git a/data/sounds/logo.wav b/data/sounds/effects/logo.wav similarity index 100% rename from data/sounds/logo.wav rename to data/sounds/effects/logo.wav diff --git a/data/sounds/good_job_commander.wav b/data/sounds/voices/good_job_commander.wav similarity index 100% rename from data/sounds/good_job_commander.wav rename to data/sounds/voices/good_job_commander.wav diff --git a/data/voices/good_job_commander.wav b/data/voices/good_job_commander.wav deleted file mode 100644 index 2c663e2..0000000 Binary files a/data/voices/good_job_commander.wav and /dev/null differ diff --git a/source/core/audio/audio_cache.cpp b/source/core/audio/audio_cache.cpp index 8c86f7d..45f9020 100644 --- a/source/core/audio/audio_cache.cpp +++ b/source/core/audio/audio_cache.cpp @@ -23,7 +23,7 @@ JA_Sound_t* AudioCache::getSound(const std::string& name) { // Normalize path: "laser_shoot.wav" → "sounds/laser_shoot.wav" std::string normalized = name; - if (normalized.find("sounds/") != 0 && normalized.find('/') == std::string::npos) { + if (normalized.find("sounds/") != 0) { normalized = "sounds/" + normalized; } @@ -57,7 +57,7 @@ JA_Music_t* AudioCache::getMusic(const std::string& name) { // Normalize path: "title.ogg" → "music/title.ogg" std::string normalized = name; - if (normalized.find("music/") != 0 && normalized.find('/') == std::string::npos) { + if (normalized.find("music/") != 0) { normalized = "music/" + normalized; } diff --git a/source/core/defaults.hpp b/source/core/defaults.hpp index 8bacdc3..b269042 100644 --- a/source/core/defaults.hpp +++ b/source/core/defaults.hpp @@ -80,18 +80,18 @@ constexpr float DEATH_DURATION = 3.0f; // Seconds of death ani constexpr float GAME_OVER_DURATION = 5.0f; // Seconds to display game over constexpr float COLLISION_SHIP_ENEMY_AMPLIFIER = 0.80f; // 80% hitbox (generous) // Transición LEVEL_START (mensajes aleatorios PRE-level) -constexpr float LEVEL_START_DURATION = 3.0f; // Duración total -constexpr float LEVEL_START_TYPING_RATIO = 0.3f; // 30% escribiendo, 70% mostrando +constexpr float LEVEL_START_DURATION = 3.0f; // Duración total +constexpr float LEVEL_START_TYPING_RATIO = 0.3f; // 30% escribiendo, 70% mostrando // Transición LEVEL_COMPLETED (mensaje "GOOD JOB COMMANDER!") -constexpr float LEVEL_COMPLETED_DURATION = 3.0f; // Duración total -constexpr float LEVEL_COMPLETED_TYPING_RATIO = 0.0f; // 0.0 = sin typewriter (directo) +constexpr float LEVEL_COMPLETED_DURATION = 3.0f; // Duración total +constexpr float LEVEL_COMPLETED_TYPING_RATIO = 0.0f; // 0.0 = sin typewriter (directo) // Transición INIT_HUD (animación inicial del HUD) -constexpr float INIT_HUD_DURATION = 3.0f; // Duración total del estado -constexpr float INIT_HUD_RECT_DURATION = 2.0f; // Duración animación rectángulo -constexpr float INIT_HUD_SCORE_DURATION = 2.5f; // Duración animación marcador -constexpr float INIT_HUD_SHIP_DURATION = 2.5f; // Duración animación nave +constexpr float INIT_HUD_DURATION = 3.0f; // Duración total del estado +constexpr float INIT_HUD_RECT_RATIO = 0.67f; // Proporción animación rectángulo (67% del total) +constexpr float INIT_HUD_SCORE_RATIO = 0.83f; // Proporción animación marcador (83% del total) +constexpr float INIT_HUD_SHIP_RATIO = 0.83f; // Proporción animación nave (83% del total) // Posición inicial de la nave en INIT_HUD (75% de altura de zona de juego) constexpr float INIT_HUD_SHIP_START_Y_RATIO = 0.75f; // 75% desde el top de PLAYAREA @@ -126,7 +126,7 @@ constexpr float FRICCIO_ANGULAR = 0.5f; // Desacceleració angular (rad/s² // Angular velocity cap for trajectory inheritance // Excess above this threshold is converted to tangential linear velocity // Prevents "vortex trap" problem with high-rotation enemies -constexpr float VELOCITAT_ROT_MAX = 1.5f; // rad/s (~86°/s) +constexpr float VELOCITAT_ROT_MAX = 1.5f; // rad/s (~86°/s) } // namespace Debris } // namespace Physics @@ -194,11 +194,12 @@ constexpr int FADE_DURATION_MS = 1000; // Fade out duration // Efectes de so (sons puntuals) namespace Sound { -constexpr float VOLUME = 1.0F; // Volumen efectos -constexpr bool ENABLED = true; // Sonidos habilitados -constexpr const char* EXPLOSION = "explosion.wav"; // Explosión -constexpr const char* LASER = "laser_shoot.wav"; // Disparo -constexpr const char* GOOD_JOB_COMMANDER = "good_job_commander.wav"; // Voz: "Good job, commander" +constexpr float VOLUME = 1.0F; // Volumen efectos +constexpr bool ENABLED = true; // Sonidos habilitados +constexpr const char* EXPLOSION = "effects/explosion.wav"; // Explosión +constexpr const char* LASER = "effects/laser_shoot.wav"; // Disparo +constexpr const char* LOGO = "effects/logo.wav"; // Logo +constexpr const char* GOOD_JOB_COMMANDER = "voices/good_job_commander.wav"; // Voz: "Good job, commander" } // namespace Sound // Enemy type configuration (tipus d'enemics) @@ -225,11 +226,11 @@ constexpr const char* SHAPE_FILE = "enemy_square.shp"; // Molinillo (agressiu - fast straight lines, proximity spin-up) namespace Molinillo { -constexpr float VELOCITAT = 50.0f; // px/s (fastest) -constexpr float CANVI_ANGLE_PROB = 0.05f; // 5% per wall hit (rare direction change) -constexpr float CANVI_ANGLE_MAX = 0.3f; // Small angle adjustments -constexpr float DROTACIO_MIN = 3.0f; // Base rotation (rad/s) [+50%] -constexpr float DROTACIO_MAX = 6.0f; // [+50%] +constexpr float VELOCITAT = 50.0f; // px/s (fastest) +constexpr float CANVI_ANGLE_PROB = 0.05f; // 5% per wall hit (rare direction change) +constexpr float CANVI_ANGLE_MAX = 0.3f; // Small angle adjustments +constexpr float DROTACIO_MIN = 3.0f; // Base rotation (rad/s) [+50%] +constexpr float DROTACIO_MAX = 6.0f; // [+50%] constexpr float DROTACIO_PROXIMITY_MULTIPLIER = 3.0f; // Spin-up multiplier when near ship constexpr float PROXIMITY_DISTANCE = 100.0f; // Distance threshold (px) constexpr const char* SHAPE_FILE = "enemy_pinwheel.shp"; @@ -256,36 +257,36 @@ constexpr float ROTACIO_ACCEL_MULTIPLIER_MAX = 4.0f; // Max speed multiplier [m // Spawn safety and invulnerability system namespace Spawn { - // Safe spawn distance from player - constexpr float SAFETY_DISTANCE_MULTIPLIER = 3.0f; // 3x ship radius - constexpr float SAFETY_DISTANCE = Defaults::Entities::SHIP_RADIUS * SAFETY_DISTANCE_MULTIPLIER; // 36.0f px - constexpr int MAX_SPAWN_ATTEMPTS = 50; // Max attempts to find safe position +// Safe spawn distance from player +constexpr float SAFETY_DISTANCE_MULTIPLIER = 3.0f; // 3x ship radius +constexpr float SAFETY_DISTANCE = Defaults::Entities::SHIP_RADIUS * SAFETY_DISTANCE_MULTIPLIER; // 36.0f px +constexpr int MAX_SPAWN_ATTEMPTS = 50; // Max attempts to find safe position - // Invulnerability system - constexpr float INVULNERABILITY_DURATION = 3.0f; // Seconds - constexpr float INVULNERABILITY_BRIGHTNESS_START = 0.3f; // Dim - constexpr float INVULNERABILITY_BRIGHTNESS_END = 0.7f; // Normal (same as Defaults::Brightness::ENEMIC) - constexpr float INVULNERABILITY_SCALE_START = 0.0f; // Invisible - constexpr float INVULNERABILITY_SCALE_END = 1.0f; // Full size +// Invulnerability system +constexpr float INVULNERABILITY_DURATION = 3.0f; // Seconds +constexpr float INVULNERABILITY_BRIGHTNESS_START = 0.3f; // Dim +constexpr float INVULNERABILITY_BRIGHTNESS_END = 0.7f; // Normal (same as Defaults::Brightness::ENEMIC) +constexpr float INVULNERABILITY_SCALE_START = 0.0f; // Invisible +constexpr float INVULNERABILITY_SCALE_END = 1.0f; // Full size } // namespace Spawn // Scoring system (puntuació per tipus d'enemic) namespace Scoring { - constexpr int PENTAGON_SCORE = 100; // Pentàgon (esquivador, 35 px/s) - constexpr int QUADRAT_SCORE = 150; // Quadrat (perseguidor, 40 px/s) - constexpr int MOLINILLO_SCORE = 200; // Molinillo (agressiu, 50 px/s) +constexpr int PENTAGON_SCORE = 100; // Pentàgon (esquivador, 35 px/s) +constexpr int QUADRAT_SCORE = 150; // Quadrat (perseguidor, 40 px/s) +constexpr int MOLINILLO_SCORE = 200; // Molinillo (agressiu, 50 px/s) } // namespace Scoring } // namespace Enemies // Floating score numbers (números flotants de puntuació) namespace FloatingScore { - constexpr float LIFETIME = 2.0f; // Duració màxima (segons) - constexpr float VELOCITY_Y = -30.0f; // Velocitat vertical (px/s, negatiu = amunt) - constexpr float VELOCITY_X = 0.0f; // Velocitat horizontal (px/s) - constexpr float SCALE = 0.75f; // Escala del text (0.75 = 75% del marcador) - constexpr float SPACING = 0.0f; // Espaiat entre caràcters - constexpr int MAX_CONCURRENT = 15; // Pool size (= MAX_ORNIS) +constexpr float LIFETIME = 2.0f; // Duració màxima (segons) +constexpr float VELOCITY_Y = -30.0f; // Velocitat vertical (px/s, negatiu = amunt) +constexpr float VELOCITY_X = 0.0f; // Velocitat horizontal (px/s) +constexpr float SCALE = 0.75f; // Escala del text (0.75 = 75% del marcador) +constexpr float SPACING = 0.0f; // Espaiat entre caràcters +constexpr int MAX_CONCURRENT = 15; // Pool size (= MAX_ORNIS) } // namespace FloatingScore } // namespace Defaults diff --git a/source/game/escenes/escena_joc.cpp b/source/game/escenes/escena_joc.cpp index 1741fa2..157f5fa 100644 --- a/source/game/escenes/escena_joc.cpp +++ b/source/game/escenes/escena_joc.cpp @@ -260,28 +260,13 @@ void EscenaJoc::actualitzar(float delta_time) { ship_progress = std::min(1.0f, ship_progress); // Calcular quant ha avançat l'animació de la nau - float ship_anim_progress = ship_progress / - (Defaults::Game::INIT_HUD_SHIP_DURATION / Defaults::Game::INIT_HUD_DURATION); + float ship_anim_progress = ship_progress / Defaults::Game::INIT_HUD_SHIP_RATIO; ship_anim_progress = std::min(1.0f, ship_anim_progress); - // [DEBUG] Imprimir progrés i posició cada 10 frames - static int debug_frame_count = 0; - if (++debug_frame_count % 10 == 0) { - std::cout << "[INIT_HUD] timer=" << stage_manager_->get_timer_transicio() - << " ship_progress=" << ship_progress - << " ship_anim_progress=" << ship_anim_progress - << " condition=" << (ship_anim_progress < 1.0f ? "TRUE" : "FALSE") - << " pos.y=" << nau_.get_centre().y - << std::endl; - } - // Actualitzar posició de la nau segons animació if (ship_anim_progress < 1.0f) { Punt pos_animada = calcular_posicio_nau_init_hud(ship_anim_progress); - std::cout << "[INIT_HUD] SETTING pos.y=" << pos_animada.y << std::endl; // [DEBUG] nau_.set_centre(pos_animada); - } else { - std::cout << "[INIT_HUD] SKIPPING update (progress >= 1.0)" << std::endl; // [DEBUG] } // Una vegada l'animació acaba, permetre control normal @@ -415,18 +400,15 @@ void EscenaJoc::dibuixar() { float global_progress = 1.0f - (timer / total_time); // Progrés del rectangle (empieza inmediatament) - float rect_progress = global_progress / - (Defaults::Game::INIT_HUD_RECT_DURATION / total_time); + float rect_progress = global_progress / Defaults::Game::INIT_HUD_RECT_RATIO; rect_progress = std::min(1.0f, rect_progress); // Progrés del marcador (empieza inmediatament) - float score_progress = global_progress / - (Defaults::Game::INIT_HUD_SCORE_DURATION / total_time); + float score_progress = global_progress / Defaults::Game::INIT_HUD_SCORE_RATIO; score_progress = std::min(1.0f, score_progress); // Progrés de la nau (empieza inmediatament) - float ship_progress = global_progress / - (Defaults::Game::INIT_HUD_SHIP_DURATION / total_time); + float ship_progress = global_progress / Defaults::Game::INIT_HUD_SHIP_RATIO; ship_progress = std::min(1.0f, ship_progress); // Dibuixar elements animats @@ -634,7 +616,7 @@ void EscenaJoc::dibuixar_marcador() { 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 + " LIFES: " + std::to_string(num_vides_) + + std::string text = "SCORE: " + score_str + " LIVES: " + std::to_string(num_vides_) + " LEVEL: " + stage_str; // Paràmetres de renderització @@ -733,7 +715,7 @@ void EscenaJoc::dibuixar_marcador_animat(float progress) { 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 + " LIFES: " + std::to_string(num_vides_) + + std::string text = "SCORE: " + score_str + " LIVES: " + std::to_string(num_vides_) + " LEVEL: " + stage_str; // Calcular dimensions diff --git a/source/game/escenes/escena_logo.cpp b/source/game/escenes/escena_logo.cpp index a2de09d..eec6c1b 100644 --- a/source/game/escenes/escena_logo.cpp +++ b/source/game/escenes/escena_logo.cpp @@ -281,7 +281,7 @@ void EscenaLogo::actualitzar(float delta_time) { // Reproduir so quan la lletra comença a aparèixer (progress > 0) if (letra_progress > 0.0f) { - Audio::get()->playSound("logo.wav", Audio::Group::INTERFACE); + Audio::get()->playSound(Defaults::Sound::LOGO, Audio::Group::GAME); so_reproduit_[i] = true; } } diff --git a/source/game/stage_system/stage_manager.cpp b/source/game/stage_system/stage_manager.cpp index 76ba60b..800f744 100644 --- a/source/game/stage_system/stage_manager.cpp +++ b/source/game/stage_system/stage_manager.cpp @@ -110,14 +110,7 @@ void StageManager::canviar_estat(EstatStage nou_estat) { void StageManager::processar_init_hud(float delta_time) { timer_transicio_ -= delta_time; - // [DEBUG] Imprimir timer cada 10 frames - static int debug_frame_count = 0; - if (++debug_frame_count % 10 == 0) { - std::cout << "[processar_init_hud] timer=" << timer_transicio_ << std::endl; - } - if (timer_transicio_ <= 0.0f) { - std::cout << "[processar_init_hud] TRANSICIÓ a LEVEL_START!" << std::endl; // [DEBUG] canviar_estat(EstatStage::LEVEL_START); } }