support close

This commit is contained in:
Love 2024-08-04 15:50:42 +02:00
parent 27ac1468c6
commit 472b439bed

View File

@ -47,22 +47,25 @@ void Game::Run() {
{
Game game;
bool quit = false;
SDL_Event event;
while (!quit) {
while (true) {
game.draw(renderer);
while (SDL_WaitEvent(&event)) {
switch (event.type) {
case SDL_QUIT:
quit = true;
break;
case SDL_KEYDOWN :
goto quit;
case SDL_KEYDOWN:
game.handle_key(event.key.keysym.sym);
game.draw(renderer);
break;
case SDL_WINDOWEVENT:
if (event.window.event == SDL_WINDOWEVENT_CLOSE)
goto quit;
break;
}
}
}
quit:;
}
SDL_DestroyRenderer(renderer);