support close
This commit is contained in:
parent
27ac1468c6
commit
472b439bed
15
src/Game.cpp
15
src/Game.cpp
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user