refactor event handling

This commit is contained in:
2024-01-30 10:54:25 +01:00
parent 9c77a9fde6
commit de58a7f405
4 changed files with 69 additions and 55 deletions

View File

@@ -53,6 +53,25 @@ SdlWrapper::~SdlWrapper() {
SDL_Quit();
}
bool SdlWrapper::handleEvents() {
SDL_Event event;
while (SDL_PollEvent(&event)) {
switch (event.type) {
case SDL_QUIT:
return false;
case SDL_KEYDOWN:
handleKeyDown(event);
break;
case SDL_KEYUP:
handleKeyUp(event);
break;
}
}
return true;
}
int SdlWrapper::loop() {
while (running) {
if (!handleEvents())