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"
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -89,9 +89,9 @@ constexpr float LEVEL_COMPLETED_TYPING_RATIO = 0.0f; // 0.0 = sin typewriter
|
||||
|
||||
// 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_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
|
||||
@@ -196,9 +196,10 @@ constexpr int FADE_DURATION_MS = 1000; // Fade out duration
|
||||
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 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)
|
||||
|
||||
@@ -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<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;
|
||||
|
||||
// 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<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;
|
||||
|
||||
// Calcular dimensions
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user