diff options
author | tcsullivan <tullivan99@gmail.com> | 2019-08-25 15:49:06 -0400 |
---|---|---|
committer | tcsullivan <tullivan99@gmail.com> | 2019-08-25 15:49:06 -0400 |
commit | 92756db816a6e0fc7ff06c6fd83d512ecb4d61f6 (patch) | |
tree | 3cf5c37f7d8056487ced45b113132d0dd3dae667 | |
parent | 9ac0fee885b562fb1097fd952a468c50b82f9ff2 (diff) |
added SDL key events
-rw-r--r-- | src/main.cpp | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/src/main.cpp b/src/main.cpp index 707c912..778ae73 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -77,8 +77,24 @@ void renderLoop(void) void logicLoop(void) { - // TODO handle logic - SDL_Delay(1000); - shouldRun.store(false); + using namespace std::chrono_literals; + + std::cout << "Press escape to exit." << std::endl; + + while (shouldRun.load()) { + for (SDL_Event event; SDL_PollEvent(&event);) { + switch (event.type) { + case SDL_KEYUP: + // Exit game on escape + if (event.key.keysym.sym == SDLK_ESCAPE) + shouldRun.store(false); + break; + default: + break; + } + } + + std::this_thread::sleep_for(100ms); + } } |