acabat INIT_HUD

This commit is contained in:
2025-12-09 22:17:35 +01:00
parent 57d623d6bc
commit b8173b205b
2 changed files with 37 additions and 2 deletions

View File

@@ -245,9 +245,15 @@ void EscenaJoc::actualitzar(float delta_time) {
switch (estat) {
case StageSystem::EstatStage::INIT_HUD: {
// Update stage manager timer
// Update stage manager timer (pot canviar l'estat!)
stage_manager_->actualitzar(delta_time);
// [FIX] Si l'estat ha canviat durant actualitzar(), sortir immediatament
// per evitar recalcular la posició de la nau amb el nou timer
if (stage_manager_->get_estat() != StageSystem::EstatStage::INIT_HUD) {
break;
}
// Calcular progrés de l'animació de la nau
float ship_progress = 1.0f - (stage_manager_->get_timer_transicio() /
Defaults::Game::INIT_HUD_DURATION);
@@ -258,10 +264,24 @@ void EscenaJoc::actualitzar(float delta_time) {
(Defaults::Game::INIT_HUD_SHIP_DURATION / Defaults::Game::INIT_HUD_DURATION);
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
@@ -270,7 +290,14 @@ void EscenaJoc::actualitzar(float delta_time) {
break;
}
case StageSystem::EstatStage::LEVEL_START:
case StageSystem::EstatStage::LEVEL_START: {
// [DEBUG] Log entrada a LEVEL_START
static bool first_entry = true;
if (first_entry) {
std::cout << "[LEVEL_START] ENTERED with pos.y=" << nau_.get_centre().y << std::endl;
first_entry = false;
}
// Update countdown timer
stage_manager_->actualitzar(delta_time);
@@ -286,6 +313,7 @@ void EscenaJoc::actualitzar(float delta_time) {
// [NEW] Update debris
debris_manager_.actualitzar(delta_time);
break;
}
case StageSystem::EstatStage::PLAYING: {
// [NEW] Update stage manager (spawns enemies, pass pause flag)

View File

@@ -110,7 +110,14 @@ 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);
}
}