Skip to content

Commit

Permalink
Add keyboard control
Browse files Browse the repository at this point in the history
  • Loading branch information
FloreauLuca committed Jul 16, 2021
1 parent f52e016 commit b094158
Show file tree
Hide file tree
Showing 3 changed files with 123 additions and 68 deletions.
12 changes: 11 additions & 1 deletion common/aer_lib/src/managers/game_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,17 @@ namespace neko::aer
endGameText[i].SetEnable(true);
endGameText[i].SetText(std::to_string(i + 1) + positionsText[i] + ": Player " + std::to_string(victoryDatas[i].index + 1) + " (Time: " + fmt::format("{:.2f}", victoryDatas[i].time) + ")");
}
if (endedGame && (time.count() > 30.0f || sdl::InputLocator::get().GetControllerButtonState(sdl::InputLocator::get().GetControllerIdVector()[0], sdl::ControllerButtonType::BUTTON_A) == sdl::ButtonState::DOWN))
auto& inputLocator = sdl::InputLocator::get();
bool buttonPressed = false;
if (!inputLocator.GetControllerIdVector().empty())
{
sdl::JoyPlayerId joyMainPlayerId = inputLocator.GetControllerIdVector()[0];
buttonPressed = inputLocator.GetControllerButtonState(joyMainPlayerId, sdl::ControllerButtonType::BUTTON_A) == sdl::ButtonState::DOWN;
}
else {
buttonPressed = inputLocator.GetKeyState(sdl::KeyCodeType::SPACE) == sdl::ButtonState::DOWN;
}
if (endedGame && (time.count() > 30.0f || buttonPressed))
{
endedGame = false;
GoBackToMenu();
Expand Down
Loading

0 comments on commit b094158

Please sign in to comment.