feat(game): skip de countdown amb JUMP/ATTACK quan numero <= 7

This commit is contained in:
JailDesigner committed 2026-05-08 22:20:39 +02:00
1 parent a717411edd
commit 486a440668
7 files changed
+123 -20

No files matched your search

+27
View File
@@ -29,4 +29,31 @@ namespace Input::Detect {
});
}
auto pressedActionButton(int player_id) -> bool {
// Teclat: les bindings actives venen d'`Options::controls()` (les
// que el menú de servei pot reescriure), no de `Defaults` cru —
// així respectem el remapping de l'usuari igual que fa el Player.
const auto& kb = (player_id == 0) ? Options::controls().keyboard_p1
: Options::controls().keyboard_p2;
const SDL_Scancode KB_JUMP = kb.jump;
const SDL_Scancode KB_ATTACK = kb.attack;
SDL_Gamepad* pad = GamepadManager::get().getForPlayer(player_id);
const SDL_JoystickID PAD_ID = (pad != nullptr) ? SDL_GetGamepadID(pad) : 0;
const auto& slot = (player_id == 0) ? Options::controls().gamepad_p1
: Options::controls().gamepad_p2;
const int JUMP_BTN = GamepadBindings::get().getButton(slot.name, slot.path, GamepadBindings::Action::JUMP);
const int ATTACK_BTN = GamepadBindings::get().getButton(slot.name, slot.path, GamepadBindings::Action::ATTACK);
return std::ranges::any_of(EventBuffer::events, [&](const SDL_Event& ev) {
if (ev.type == SDL_EVENT_KEY_DOWN && (ev.key.scancode == KB_JUMP || ev.key.scancode == KB_ATTACK)) {
return true;
}
if (ev.type == SDL_EVENT_GAMEPAD_BUTTON_DOWN && pad != nullptr && ev.gbutton.which == PAD_ID) {
const int BTN = static_cast<int>(ev.gbutton.button);
if (BTN == JUMP_BTN || BTN == ATTACK_BTN) { return true; }
}
return false;
});
}
} // namespace Input::Detect