From 2c2ca14dd8c47ccca6d0db1b728ab4a00dbfb0a4 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Mon, 21 Mar 2022 10:48:48 -0400 Subject: can't just hold space to get through messages --- src/sign.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/sign.cpp') diff --git a/src/sign.cpp b/src/sign.cpp index e488108..46a1d6e 100644 --- a/src/sign.cpp +++ b/src/sign.cpp @@ -52,10 +52,13 @@ void Sign::displayMessage(std::string text) { void Sign::update(size_t dt, Game& game) { SDL_Event e; + bool pressedSpace = false; while (SDL_PollEvent(&e)) { if (e.type == SDL_QUIT) { game.quit = true; + } else if (e.type == SDL_KEYDOWN && e.key.keysym.sym == SDLK_SPACE && e.key.repeat == 0) { + pressedSpace = true; } } @@ -81,8 +84,7 @@ void Sign::update(size_t dt, Game& game) { break; } case SignInstructionState::Visible: { - const Uint8* state = SDL_GetKeyboardState(NULL); - if (state[SDL_SCANCODE_SPACE]) { + if (pressedSpace) { bool fullyRevealed = true; for (const SignLine& line : linesToShow) { if (line.charsRevealed != line.text.size()) { -- cgit 1.4.1