INIT_HUD amb temps de les animacions per percentatge
ordenats en subcarpetes els fitxers d'audio corregit typo LIFES a LIVES
This commit is contained in:
Binary file not shown.
@@ -23,7 +23,7 @@ JA_Sound_t* AudioCache::getSound(const std::string& name) {
|
|||||||
|
|
||||||
// Normalize path: "laser_shoot.wav" → "sounds/laser_shoot.wav"
|
// Normalize path: "laser_shoot.wav" → "sounds/laser_shoot.wav"
|
||||||
std::string normalized = name;
|
std::string normalized = name;
|
||||||
if (normalized.find("sounds/") != 0 && normalized.find('/') == std::string::npos) {
|
if (normalized.find("sounds/") != 0) {
|
||||||
normalized = "sounds/" + normalized;
|
normalized = "sounds/" + normalized;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,7 +57,7 @@ JA_Music_t* AudioCache::getMusic(const std::string& name) {
|
|||||||
|
|
||||||
// Normalize path: "title.ogg" → "music/title.ogg"
|
// Normalize path: "title.ogg" → "music/title.ogg"
|
||||||
std::string normalized = name;
|
std::string normalized = name;
|
||||||
if (normalized.find("music/") != 0 && normalized.find('/') == std::string::npos) {
|
if (normalized.find("music/") != 0) {
|
||||||
normalized = "music/" + normalized;
|
normalized = "music/" + normalized;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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 GAME_OVER_DURATION = 5.0f; // Seconds to display game over
|
||||||
constexpr float COLLISION_SHIP_ENEMY_AMPLIFIER = 0.80f; // 80% hitbox (generous)
|
constexpr float COLLISION_SHIP_ENEMY_AMPLIFIER = 0.80f; // 80% hitbox (generous)
|
||||||
// Transición LEVEL_START (mensajes aleatorios PRE-level)
|
// Transición LEVEL_START (mensajes aleatorios PRE-level)
|
||||||
constexpr float LEVEL_START_DURATION = 3.0f; // Duración total
|
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_TYPING_RATIO = 0.3f; // 30% escribiendo, 70% mostrando
|
||||||
|
|
||||||
// Transición LEVEL_COMPLETED (mensaje "GOOD JOB COMMANDER!")
|
// Transición LEVEL_COMPLETED (mensaje "GOOD JOB COMMANDER!")
|
||||||
constexpr float LEVEL_COMPLETED_DURATION = 3.0f; // Duración total
|
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_TYPING_RATIO = 0.0f; // 0.0 = sin typewriter (directo)
|
||||||
|
|
||||||
// Transición INIT_HUD (animación inicial del HUD)
|
// 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_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_RECT_RATIO = 0.67f; // Proporción animación rectángulo (67% del total)
|
||||||
constexpr float INIT_HUD_SCORE_DURATION = 2.5f; // Duración animación marcador
|
constexpr float INIT_HUD_SCORE_RATIO = 0.83f; // Proporción animación marcador (83% del total)
|
||||||
constexpr float INIT_HUD_SHIP_DURATION = 2.5f; // Duración animación nave
|
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)
|
// 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
|
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
|
// Angular velocity cap for trajectory inheritance
|
||||||
// Excess above this threshold is converted to tangential linear velocity
|
// Excess above this threshold is converted to tangential linear velocity
|
||||||
// Prevents "vortex trap" problem with high-rotation enemies
|
// 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 Debris
|
||||||
} // namespace Physics
|
} // namespace Physics
|
||||||
|
|
||||||
@@ -194,11 +194,12 @@ constexpr int FADE_DURATION_MS = 1000; // Fade out duration
|
|||||||
|
|
||||||
// Efectes de so (sons puntuals)
|
// Efectes de so (sons puntuals)
|
||||||
namespace Sound {
|
namespace Sound {
|
||||||
constexpr float VOLUME = 1.0F; // Volumen efectos
|
constexpr float VOLUME = 1.0F; // Volumen efectos
|
||||||
constexpr bool ENABLED = true; // Sonidos habilitados
|
constexpr bool ENABLED = true; // Sonidos habilitados
|
||||||
constexpr const char* EXPLOSION = "explosion.wav"; // Explosión
|
constexpr const char* EXPLOSION = "effects/explosion.wav"; // Explosión
|
||||||
constexpr const char* LASER = "laser_shoot.wav"; // Disparo
|
constexpr const char* LASER = "effects/laser_shoot.wav"; // Disparo
|
||||||
constexpr const char* GOOD_JOB_COMMANDER = "good_job_commander.wav"; // Voz: "Good job, commander"
|
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
|
} // namespace Sound
|
||||||
|
|
||||||
// Enemy type configuration (tipus d'enemics)
|
// 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)
|
// Molinillo (agressiu - fast straight lines, proximity spin-up)
|
||||||
namespace Molinillo {
|
namespace Molinillo {
|
||||||
constexpr float VELOCITAT = 50.0f; // px/s (fastest)
|
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_PROB = 0.05f; // 5% per wall hit (rare direction change)
|
||||||
constexpr float CANVI_ANGLE_MAX = 0.3f; // Small angle adjustments
|
constexpr float CANVI_ANGLE_MAX = 0.3f; // Small angle adjustments
|
||||||
constexpr float DROTACIO_MIN = 3.0f; // Base rotation (rad/s) [+50%]
|
constexpr float DROTACIO_MIN = 3.0f; // Base rotation (rad/s) [+50%]
|
||||||
constexpr float DROTACIO_MAX = 6.0f; // [+50%]
|
constexpr float DROTACIO_MAX = 6.0f; // [+50%]
|
||||||
constexpr float DROTACIO_PROXIMITY_MULTIPLIER = 3.0f; // Spin-up multiplier when near ship
|
constexpr float DROTACIO_PROXIMITY_MULTIPLIER = 3.0f; // Spin-up multiplier when near ship
|
||||||
constexpr float PROXIMITY_DISTANCE = 100.0f; // Distance threshold (px)
|
constexpr float PROXIMITY_DISTANCE = 100.0f; // Distance threshold (px)
|
||||||
constexpr const char* SHAPE_FILE = "enemy_pinwheel.shp";
|
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
|
// Spawn safety and invulnerability system
|
||||||
namespace Spawn {
|
namespace Spawn {
|
||||||
// Safe spawn distance from player
|
// Safe spawn distance from player
|
||||||
constexpr float SAFETY_DISTANCE_MULTIPLIER = 3.0f; // 3x ship radius
|
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 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
|
constexpr int MAX_SPAWN_ATTEMPTS = 50; // Max attempts to find safe position
|
||||||
|
|
||||||
// Invulnerability system
|
// Invulnerability system
|
||||||
constexpr float INVULNERABILITY_DURATION = 3.0f; // Seconds
|
constexpr float INVULNERABILITY_DURATION = 3.0f; // Seconds
|
||||||
constexpr float INVULNERABILITY_BRIGHTNESS_START = 0.3f; // Dim
|
constexpr float INVULNERABILITY_BRIGHTNESS_START = 0.3f; // Dim
|
||||||
constexpr float INVULNERABILITY_BRIGHTNESS_END = 0.7f; // Normal (same as Defaults::Brightness::ENEMIC)
|
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_START = 0.0f; // Invisible
|
||||||
constexpr float INVULNERABILITY_SCALE_END = 1.0f; // Full size
|
constexpr float INVULNERABILITY_SCALE_END = 1.0f; // Full size
|
||||||
} // namespace Spawn
|
} // namespace Spawn
|
||||||
|
|
||||||
// Scoring system (puntuació per tipus d'enemic)
|
// Scoring system (puntuació per tipus d'enemic)
|
||||||
namespace Scoring {
|
namespace Scoring {
|
||||||
constexpr int PENTAGON_SCORE = 100; // Pentàgon (esquivador, 35 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 QUADRAT_SCORE = 150; // Quadrat (perseguidor, 40 px/s)
|
||||||
constexpr int MOLINILLO_SCORE = 200; // Molinillo (agressiu, 50 px/s)
|
constexpr int MOLINILLO_SCORE = 200; // Molinillo (agressiu, 50 px/s)
|
||||||
} // namespace Scoring
|
} // namespace Scoring
|
||||||
|
|
||||||
} // namespace Enemies
|
} // namespace Enemies
|
||||||
|
|
||||||
// Floating score numbers (números flotants de puntuació)
|
// Floating score numbers (números flotants de puntuació)
|
||||||
namespace FloatingScore {
|
namespace FloatingScore {
|
||||||
constexpr float LIFETIME = 2.0f; // Duració màxima (segons)
|
constexpr float LIFETIME = 2.0f; // Duració màxima (segons)
|
||||||
constexpr float VELOCITY_Y = -30.0f; // Velocitat vertical (px/s, negatiu = amunt)
|
constexpr float VELOCITY_Y = -30.0f; // Velocitat vertical (px/s, negatiu = amunt)
|
||||||
constexpr float VELOCITY_X = 0.0f; // Velocitat horizontal (px/s)
|
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 SCALE = 0.75f; // Escala del text (0.75 = 75% del marcador)
|
||||||
constexpr float SPACING = 0.0f; // Espaiat entre caràcters
|
constexpr float SPACING = 0.0f; // Espaiat entre caràcters
|
||||||
constexpr int MAX_CONCURRENT = 15; // Pool size (= MAX_ORNIS)
|
constexpr int MAX_CONCURRENT = 15; // Pool size (= MAX_ORNIS)
|
||||||
} // namespace FloatingScore
|
} // namespace FloatingScore
|
||||||
|
|
||||||
} // namespace Defaults
|
} // namespace Defaults
|
||||||
|
|||||||
@@ -260,28 +260,13 @@ void EscenaJoc::actualitzar(float delta_time) {
|
|||||||
ship_progress = std::min(1.0f, ship_progress);
|
ship_progress = std::min(1.0f, ship_progress);
|
||||||
|
|
||||||
// Calcular quant ha avançat l'animació de la nau
|
// Calcular quant ha avançat l'animació de la nau
|
||||||
float ship_anim_progress = ship_progress /
|
float ship_anim_progress = ship_progress / Defaults::Game::INIT_HUD_SHIP_RATIO;
|
||||||
(Defaults::Game::INIT_HUD_SHIP_DURATION / Defaults::Game::INIT_HUD_DURATION);
|
|
||||||
ship_anim_progress = std::min(1.0f, ship_anim_progress);
|
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ó
|
// Actualitzar posició de la nau segons animació
|
||||||
if (ship_anim_progress < 1.0f) {
|
if (ship_anim_progress < 1.0f) {
|
||||||
Punt pos_animada = calcular_posicio_nau_init_hud(ship_anim_progress);
|
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);
|
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
|
// Una vegada l'animació acaba, permetre control normal
|
||||||
@@ -415,18 +400,15 @@ void EscenaJoc::dibuixar() {
|
|||||||
float global_progress = 1.0f - (timer / total_time);
|
float global_progress = 1.0f - (timer / total_time);
|
||||||
|
|
||||||
// Progrés del rectangle (empieza inmediatament)
|
// Progrés del rectangle (empieza inmediatament)
|
||||||
float rect_progress = global_progress /
|
float rect_progress = global_progress / Defaults::Game::INIT_HUD_RECT_RATIO;
|
||||||
(Defaults::Game::INIT_HUD_RECT_DURATION / total_time);
|
|
||||||
rect_progress = std::min(1.0f, rect_progress);
|
rect_progress = std::min(1.0f, rect_progress);
|
||||||
|
|
||||||
// Progrés del marcador (empieza inmediatament)
|
// Progrés del marcador (empieza inmediatament)
|
||||||
float score_progress = global_progress /
|
float score_progress = global_progress / Defaults::Game::INIT_HUD_SCORE_RATIO;
|
||||||
(Defaults::Game::INIT_HUD_SCORE_DURATION / total_time);
|
|
||||||
score_progress = std::min(1.0f, score_progress);
|
score_progress = std::min(1.0f, score_progress);
|
||||||
|
|
||||||
// Progrés de la nau (empieza inmediatament)
|
// Progrés de la nau (empieza inmediatament)
|
||||||
float ship_progress = global_progress /
|
float ship_progress = global_progress / Defaults::Game::INIT_HUD_SHIP_RATIO;
|
||||||
(Defaults::Game::INIT_HUD_SHIP_DURATION / total_time);
|
|
||||||
ship_progress = std::min(1.0f, ship_progress);
|
ship_progress = std::min(1.0f, ship_progress);
|
||||||
|
|
||||||
// Dibuixar elements animats
|
// Dibuixar elements animats
|
||||||
@@ -634,7 +616,7 @@ void EscenaJoc::dibuixar_marcador() {
|
|||||||
std::string score_str = std::to_string(puntuacio_total_);
|
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;
|
score_str = std::string(5 - std::min(5, static_cast<int>(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;
|
" LEVEL: " + stage_str;
|
||||||
|
|
||||||
// Paràmetres de renderització
|
// Paràmetres de renderització
|
||||||
@@ -733,7 +715,7 @@ void EscenaJoc::dibuixar_marcador_animat(float progress) {
|
|||||||
std::string score_str = std::to_string(puntuacio_total_);
|
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;
|
score_str = std::string(5 - std::min(5, static_cast<int>(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;
|
" LEVEL: " + stage_str;
|
||||||
|
|
||||||
// Calcular dimensions
|
// Calcular dimensions
|
||||||
|
|||||||
@@ -281,7 +281,7 @@ void EscenaLogo::actualitzar(float delta_time) {
|
|||||||
|
|
||||||
// Reproduir so quan la lletra comença a aparèixer (progress > 0)
|
// 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("logo.wav", Audio::Group::INTERFACE);
|
Audio::get()->playSound(Defaults::Sound::LOGO, Audio::Group::GAME);
|
||||||
so_reproduit_[i] = true;
|
so_reproduit_[i] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -110,14 +110,7 @@ void StageManager::canviar_estat(EstatStage nou_estat) {
|
|||||||
void StageManager::processar_init_hud(float delta_time) {
|
void StageManager::processar_init_hud(float delta_time) {
|
||||||
timer_transicio_ -= 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) {
|
if (timer_transicio_ <= 0.0f) {
|
||||||
std::cout << "[processar_init_hud] TRANSICIÓ a LEVEL_START!" << std::endl; // [DEBUG]
|
|
||||||
canviar_estat(EstatStage::LEVEL_START);
|
canviar_estat(EstatStage::LEVEL_START);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user