feat(game): skip de countdown amb JUMP/ATTACK quan numero <= 7
This commit is contained in:
1 parent
a717411edd
commit
486a440668
7 files changed
+123
-20
No files matched your search
@@ -1231,26 +1231,43 @@ void GameScene::updateGameOverFlow(int delta_ms) {
|
||||
}
|
||||
}
|
||||
|
||||
// Tick del so del countdown: cada vegada que el número visible
|
||||
// canvia (incloent l'aparició del primer valor i del 0), reproduïm
|
||||
// el so configurat. La detecció es fa post-`advance` perquè el
|
||||
// canvi de fase 0 → 1 arribi a aparèixer com a transició -1 → start.
|
||||
// En la transició cap a GAME_OVER el state ja no és CONTINUE_PROMPT
|
||||
// i la branca s'omet — així no sona un "tick" extra al saltar.
|
||||
if (game_over_state_ == GameOverFsm::State::CONTINUE_PROMPT) {
|
||||
const int CURRENT = GameOverFsm::countdownSecondsRemaining(
|
||||
game_over_state_,
|
||||
game_over_transition_,
|
||||
game_over_config_);
|
||||
if (game_over_transition_.phase == 1 && CURRENT != last_countdown_value_) {
|
||||
last_countdown_value_ = CURRENT;
|
||||
const auto& key = game_over_config_.countdown_sound_key;
|
||||
if (!key.empty()) {
|
||||
if (auto* audio = Audio::get(); audio != nullptr) {
|
||||
audio->playSound(key, Audio::Group::INTERFACE);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Skip i tick del so del countdown viuen en helpers per acotar
|
||||
// la complexitat cognitiva d'aquesta funció. Skip primer perquè
|
||||
// el tick del so soni amb el valor nou si la pulsació ha avançat.
|
||||
handleCountdownSkip();
|
||||
emitCountdownTickIfChanged();
|
||||
}
|
||||
|
||||
void GameScene::handleCountdownSkip() {
|
||||
if (game_over_state_ != GameOverFsm::State::CONTINUE_PROMPT) { return; }
|
||||
if (game_over_transition_.phase != 1) { return; }
|
||||
const int CURRENT = GameOverFsm::countdownSecondsRemaining(
|
||||
game_over_state_,
|
||||
game_over_transition_,
|
||||
game_over_config_);
|
||||
if (CURRENT <= 0) { return; }
|
||||
if (CURRENT > game_over_config_.skip_below_or_equal) { return; }
|
||||
const bool ANY_ACTION = Input::Detect::pressedActionButton(0) || Input::Detect::pressedActionButton(1);
|
||||
if (!ANY_ACTION) { return; }
|
||||
GameOverFsm::skipToNextCountdown(
|
||||
game_over_state_,
|
||||
game_over_transition_,
|
||||
game_over_config_);
|
||||
}
|
||||
|
||||
void GameScene::emitCountdownTickIfChanged() {
|
||||
if (game_over_state_ != GameOverFsm::State::CONTINUE_PROMPT) { return; }
|
||||
if (game_over_transition_.phase != 1) { return; }
|
||||
const int CURRENT = GameOverFsm::countdownSecondsRemaining(
|
||||
game_over_state_,
|
||||
game_over_transition_,
|
||||
game_over_config_);
|
||||
if (CURRENT == last_countdown_value_) { return; }
|
||||
last_countdown_value_ = CURRENT;
|
||||
const auto& key = game_over_config_.countdown_sound_key;
|
||||
if (key.empty()) { return; }
|
||||
if (auto* audio = Audio::get(); audio != nullptr) {
|
||||
audio->playSound(key, Audio::Group::INTERFACE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user