Commit 657a76aa09e5b8adb11342f59cf0a8b614762f53
1 parent
e8a66472
Checking for quit in isKeyDown
Showing
1 changed file
with
7 additions
and
1 deletions
primlib.c
| ... | ... | @@ -47,7 +47,6 @@ void gfx_filledTriangle(int x1, int y1, int x2, int y2, int x3, int y3, enum col |
| 47 | 47 | 255); |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - | |
| 51 | 50 | void gfx_rect(int x1, int y1, int x2, int y2, enum color c) { |
| 52 | 51 | assert(c < COLOR_MAX); |
| 53 | 52 | rectangleRGBA(renderer, x1, y1, x2, y2, colors[c].r, colors[c].g, colors[c].b, |
| ... | ... | @@ -113,6 +112,13 @@ int gfx_isKeyDown(int key) { |
| 113 | 112 | const Uint8 *keytable; |
| 114 | 113 | int numkeys; |
| 115 | 114 | SDL_PumpEvents(); |
| 115 | + SDL_Event event; | |
| 116 | + if(SDL_PollEvent(&event)) { | |
| 117 | + switch (event.type) { | |
| 118 | + case SDL_QUIT: | |
| 119 | + exit(3); | |
| 120 | + } | |
| 121 | + } | |
| 116 | 122 | keytable = SDL_GetKeyboardState(&numkeys); |
| 117 | 123 | SDL_Scancode code = SDL_GetScancodeFromKey(key); |
| 118 | 124 | assert(code < numkeys); | ... | ... |