continue counter ara arriba fins a 0
This commit is contained in:
@@ -1166,6 +1166,13 @@ void EscenaJoc::disparar_bala(uint8_t player_id) {
|
|||||||
|
|
||||||
// ==================== CONTINUE & JOIN SYSTEM ====================
|
// ==================== CONTINUE & JOIN SYSTEM ====================
|
||||||
|
|
||||||
|
void EscenaJoc::check_and_apply_continue_timeout() {
|
||||||
|
if (continue_counter_ < 0) {
|
||||||
|
estat_game_over_ = EstatGameOver::GAME_OVER;
|
||||||
|
game_over_timer_ = Defaults::Game::GAME_OVER_DURATION;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void EscenaJoc::actualitzar_continue(float delta_time) {
|
void EscenaJoc::actualitzar_continue(float delta_time) {
|
||||||
continue_tick_timer_ -= delta_time;
|
continue_tick_timer_ -= delta_time;
|
||||||
|
|
||||||
@@ -1173,13 +1180,12 @@ void EscenaJoc::actualitzar_continue(float delta_time) {
|
|||||||
continue_counter_--;
|
continue_counter_--;
|
||||||
continue_tick_timer_ = Defaults::Game::CONTINUE_TICK_DURATION;
|
continue_tick_timer_ = Defaults::Game::CONTINUE_TICK_DURATION;
|
||||||
|
|
||||||
// Play tick sound
|
// Check if timeout reached (counter < 0)
|
||||||
Audio::get()->playSound(Defaults::Sound::CONTINUE, Audio::Group::GAME);
|
check_and_apply_continue_timeout();
|
||||||
|
|
||||||
if (continue_counter_ <= 0) {
|
// Play sound only if still in CONTINUE state (not transitioned to GAME_OVER)
|
||||||
// Timeout → final game over
|
if (estat_game_over_ == EstatGameOver::CONTINUE) {
|
||||||
estat_game_over_ = EstatGameOver::GAME_OVER;
|
Audio::get()->playSound(Defaults::Sound::CONTINUE, Audio::Group::GAME);
|
||||||
game_over_timer_ = Defaults::Game::GAME_OVER_DURATION;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1255,12 +1261,12 @@ void EscenaJoc::processar_input_continue() {
|
|||||||
if (thrust_p1 || thrust_p2 || fire_p1 || fire_p2) {
|
if (thrust_p1 || thrust_p2 || fire_p1 || fire_p2) {
|
||||||
continue_counter_--;
|
continue_counter_--;
|
||||||
|
|
||||||
// Play tick sound on manual decrement
|
// Check if timeout reached (counter < 0)
|
||||||
Audio::get()->playSound(Defaults::Sound::CONTINUE, Audio::Group::GAME);
|
check_and_apply_continue_timeout();
|
||||||
|
|
||||||
if (continue_counter_ <= 0) {
|
// Play sound only if still in CONTINUE state
|
||||||
estat_game_over_ = EstatGameOver::GAME_OVER;
|
if (estat_game_over_ == EstatGameOver::CONTINUE) {
|
||||||
game_over_timer_ = Defaults::Game::GAME_OVER_DURATION;
|
Audio::get()->playSound(Defaults::Sound::CONTINUE, Audio::Group::GAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset timer to prevent double-decrement
|
// Reset timer to prevent double-decrement
|
||||||
|
|||||||
@@ -92,6 +92,7 @@ class EscenaJoc {
|
|||||||
void unir_jugador(uint8_t player_id); // Join inactive player mid-game
|
void unir_jugador(uint8_t player_id); // Join inactive player mid-game
|
||||||
void processar_input_continue(); // Handle input during continue screen
|
void processar_input_continue(); // Handle input during continue screen
|
||||||
void actualitzar_continue(float delta_time); // Update continue countdown
|
void actualitzar_continue(float delta_time); // Update continue countdown
|
||||||
|
void check_and_apply_continue_timeout(); // Check if continue timed out and transition to GAME_OVER
|
||||||
void dibuixar_continue(); // Draw continue screen
|
void dibuixar_continue(); // Draw continue screen
|
||||||
|
|
||||||
// [NEW] Stage system helpers
|
// [NEW] Stage system helpers
|
||||||
|
|||||||
Reference in New Issue
Block a user