q to quit

This commit is contained in:
ktyl 2021-08-08 15:29:13 +01:00
parent 21b8c0910d
commit 3b7d413390
1 changed files with 20 additions and 2 deletions

View File

@ -2,9 +2,27 @@
int checkQuit() int checkQuit()
{ {
int quit = 0;
SDL_Event event; SDL_Event event;
if (SDL_PollEvent(&event) && event.type == SDL_QUIT) return 1; if (SDL_PollEvent(&event))
{
switch(event.type)
{
case SDL_QUIT:
quit = 1;
break;
return 0; case SDL_KEYDOWN:
if (event.key.keysym.sym == SDLK_q)
{
quit = 1;
}
default:
break;
}
}
return quit;
} }