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 ====================
|
||||
|
||||
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) {
|
||||
continue_tick_timer_ -= delta_time;
|
||||
|
||||
@@ -1173,13 +1180,12 @@ void EscenaJoc::actualitzar_continue(float delta_time) {
|
||||
continue_counter_--;
|
||||
continue_tick_timer_ = Defaults::Game::CONTINUE_TICK_DURATION;
|
||||
|
||||
// Play tick sound
|
||||
Audio::get()->playSound(Defaults::Sound::CONTINUE, Audio::Group::GAME);
|
||||
// Check if timeout reached (counter < 0)
|
||||
check_and_apply_continue_timeout();
|
||||
|
||||
if (continue_counter_ <= 0) {
|
||||
// Timeout → final game over
|
||||
estat_game_over_ = EstatGameOver::GAME_OVER;
|
||||
game_over_timer_ = Defaults::Game::GAME_OVER_DURATION;
|
||||
// Play sound only if still in CONTINUE state (not transitioned to GAME_OVER)
|
||||
if (estat_game_over_ == EstatGameOver::CONTINUE) {
|
||||
Audio::get()->playSound(Defaults::Sound::CONTINUE, Audio::Group::GAME);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1255,12 +1261,12 @@ void EscenaJoc::processar_input_continue() {
|
||||
if (thrust_p1 || thrust_p2 || fire_p1 || fire_p2) {
|
||||
continue_counter_--;
|
||||
|
||||
// Play tick sound on manual decrement
|
||||
Audio::get()->playSound(Defaults::Sound::CONTINUE, Audio::Group::GAME);
|
||||
// Check if timeout reached (counter < 0)
|
||||
check_and_apply_continue_timeout();
|
||||
|
||||
if (continue_counter_ <= 0) {
|
||||
estat_game_over_ = EstatGameOver::GAME_OVER;
|
||||
game_over_timer_ = Defaults::Game::GAME_OVER_DURATION;
|
||||
// Play sound only if still in CONTINUE state
|
||||
if (estat_game_over_ == EstatGameOver::CONTINUE) {
|
||||
Audio::get()->playSound(Defaults::Sound::CONTINUE, Audio::Group::GAME);
|
||||
}
|
||||
|
||||
// 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 processar_input_continue(); // Handle input during continue screen
|
||||
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
|
||||
|
||||
// [NEW] Stage system helpers
|
||||
|
||||
Reference in New Issue
Block a user