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
|
||||
|
||||
Reference in New Issue
Block a user