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;
|
Game game;
|
||||||
bool quit = false;
|
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
while (!quit) {
|
while (true) {
|
||||||
game.draw(renderer);
|
game.draw(renderer);
|
||||||
while (SDL_WaitEvent(&event)) {
|
while (SDL_WaitEvent(&event)) {
|
||||||
switch (event.type) {
|
switch (event.type) {
|
||||||
case SDL_QUIT:
|
case SDL_QUIT:
|
||||||
quit = true;
|
goto quit;
|
||||||
break;
|
case SDL_KEYDOWN:
|
||||||
case SDL_KEYDOWN :
|
|
||||||
game.handle_key(event.key.keysym.sym);
|
game.handle_key(event.key.keysym.sym);
|
||||||
game.draw(renderer);
|
game.draw(renderer);
|
||||||
|
break;
|
||||||
|
case SDL_WINDOWEVENT:
|
||||||
|
if (event.window.event == SDL_WINDOWEVENT_CLOSE)
|
||||||
|
goto quit;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
quit:;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_DestroyRenderer(renderer);
|
SDL_DestroyRenderer(renderer);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user