fix(game): HUD lives desde YAML, prompt P1 en single-P2, countdown 9..0 configurable
This commit is contained in:
1 parent
78e164fce4
commit
5e862ceadc
9 files changed
+66
-29
No files matched your search
@@ -36,7 +36,7 @@ namespace GameOverFsm {
|
||||
cfg.continue_text_enter_ms = readChildInt(n, "continue_text_enter_ms", cfg.continue_text_enter_ms);
|
||||
cfg.continue_text_hold_ms = readChildInt(n, "continue_text_hold_ms", cfg.continue_text_hold_ms);
|
||||
cfg.continue_text_exit_ms = readChildInt(n, "continue_text_exit_ms", cfg.continue_text_exit_ms);
|
||||
cfg.continue_count_steps = readChildInt(n, "continue_count_steps", cfg.continue_count_steps);
|
||||
cfg.continue_count_start = readChildInt(n, "continue_count_start", cfg.continue_count_start);
|
||||
cfg.game_over_text_hold_ms = readChildInt(n, "game_over_text_hold_ms", cfg.game_over_text_hold_ms);
|
||||
cfg.game_over_text_exit_ms = readChildInt(n, "game_over_text_exit_ms", cfg.game_over_text_exit_ms);
|
||||
cfg.game_over_wait_ms = readChildInt(n, "game_over_wait_ms", cfg.game_over_wait_ms);
|
||||
@@ -112,10 +112,16 @@ namespace GameOverFsm {
|
||||
auto countdownSecondsRemaining(State current, const Transition& t, const Config& cfg) -> int {
|
||||
if (current != State::CONTINUE_PROMPT) { return 0; }
|
||||
if (t.phase != 1) { return 0; }
|
||||
const int STEPS = std::max(1, cfg.continue_count_steps);
|
||||
const int STEP_MS = std::max(1, cfg.continue_text_hold_ms / STEPS);
|
||||
// La sèrie és [start, start-1, ..., 1, 0]: en total `start+1`
|
||||
// graons. El primer número visible és `start` i l'últim 0 es
|
||||
// manté durant el seu graó abans que la fase 1 acabi i la FSM
|
||||
// salti a GAME_OVER. Si `start == 0` només es mostra "0"
|
||||
// durant tot el hold.
|
||||
const int START = std::max(0, cfg.continue_count_start);
|
||||
const int STEP_COUNT = START + 1;
|
||||
const int STEP_MS = std::max(1, cfg.continue_text_hold_ms / STEP_COUNT);
|
||||
const int CONSUMED = t.elapsed_ms / STEP_MS;
|
||||
return std::clamp(STEPS - CONSUMED, 0, STEPS);
|
||||
return std::clamp(START - CONSUMED, 0, START);
|
||||
}
|
||||
|
||||
auto stateName(State s) -> const char* {
|
||||
|
||||
Reference in new issue
Block a user