From 523342fed9aa9618ec3d4e77b2a6fda5536cc9d3 Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Tue, 9 Dec 2025 11:45:28 +0100 Subject: [PATCH] canvis en el inici i final de fase --- source/game/escenes/escena_joc.cpp | 58 ++++++++++++++++++++++++++++-- 1 file changed, 55 insertions(+), 3 deletions(-) diff --git a/source/game/escenes/escena_joc.cpp b/source/game/escenes/escena_joc.cpp index 1544ea9..03c9031 100644 --- a/source/game/escenes/escena_joc.cpp +++ b/source/game/escenes/escena_joc.cpp @@ -233,8 +233,20 @@ void EscenaJoc::actualitzar(float delta_time) { switch (estat) { case StageSystem::EstatStage::LEVEL_START: - // Frozen gameplay, countdown timer only + // Update countdown timer stage_manager_->actualitzar(delta_time); + + // [NEW] Allow ship movement and shooting during intro + nau_.processar_input(delta_time); + nau_.actualitzar(delta_time); + + // [NEW] Update bullets + for (auto& bala : bales_) { + bala.actualitzar(delta_time); + } + + // [NEW] Update debris + debris_manager_.actualitzar(delta_time); break; case StageSystem::EstatStage::PLAYING: { @@ -271,8 +283,20 @@ void EscenaJoc::actualitzar(float delta_time) { } case StageSystem::EstatStage::LEVEL_COMPLETED: - // Frozen gameplay, countdown timer only + // Update countdown timer stage_manager_->actualitzar(delta_time); + + // [NEW] Allow ship movement and shooting during outro + nau_.processar_input(delta_time); + nau_.actualitzar(delta_time); + + // [NEW] Update bullets (allow last shots to continue) + for (auto& bala : bales_) { + bala.actualitzar(delta_time); + } + + // [NEW] Update debris (from last destroyed enemies) + debris_manager_.actualitzar(delta_time); break; } } @@ -318,6 +342,20 @@ void EscenaJoc::dibuixar() { switch (estat) { case StageSystem::EstatStage::LEVEL_START: + // [NEW] Draw ship if alive + if (itocado_ == 0.0f) { + nau_.dibuixar(); + } + + // [NEW] Draw bullets + for (const auto& bala : bales_) { + bala.dibuixar(); + } + + // [NEW] Draw debris + debris_manager_.dibuixar(); + + // [EXISTING] Draw intro message and score dibuixar_missatge_stage(StageSystem::Constants::MISSATGE_LEVEL_START); dibuixar_marcador(); break; @@ -341,6 +379,20 @@ void EscenaJoc::dibuixar() { break; case StageSystem::EstatStage::LEVEL_COMPLETED: + // [NEW] Draw ship if alive + if (itocado_ == 0.0f) { + nau_.dibuixar(); + } + + // [NEW] Draw bullets (allow last shots to be visible) + for (const auto& bala : bales_) { + bala.dibuixar(); + } + + // [NEW] Draw debris (from last destroyed enemies) + debris_manager_.dibuixar(); + + // [EXISTING] Draw completion message and score dibuixar_missatge_stage(StageSystem::Constants::MISSATGE_LEVEL_COMPLETED); dibuixar_marcador(); break; @@ -603,7 +655,7 @@ void EscenaJoc::dibuixar_missatge_stage(const std::string& missatge) { const SDL_FRect& play_area = Defaults::Zones::PLAYAREA; float x = play_area.x + (play_area.w - text_width) / 2.0f; - float y = play_area.y + (play_area.h - text_height) / 2.0f; + float y = play_area.y + (play_area.h * 0.25f) - (text_height / 2.0f); Punt pos = {static_cast(x), static_cast(y)}; text_.render(missatge, pos, escala, spacing);