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,7 +47,6 @@ void gfx_filledTriangle(int x1, int y1, int x2, int y2, int x3, int y3, enum col | ||
| 47 | 255); | 47 | 255); |
| 48 | } | 48 | } |
| 49 | 49 | ||
| 50 | - | ||
| 51 | void gfx_rect(int x1, int y1, int x2, int y2, enum color c) { | 50 | void gfx_rect(int x1, int y1, int x2, int y2, enum color c) { |
| 52 | assert(c < COLOR_MAX); | 51 | assert(c < COLOR_MAX); |
| 53 | rectangleRGBA(renderer, x1, y1, x2, y2, colors[c].r, colors[c].g, colors[c].b, | 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,6 +112,13 @@ int gfx_isKeyDown(int key) { | ||
| 113 | const Uint8 *keytable; | 112 | const Uint8 *keytable; |
| 114 | int numkeys; | 113 | int numkeys; |
| 115 | SDL_PumpEvents(); | 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 | keytable = SDL_GetKeyboardState(&numkeys); | 122 | keytable = SDL_GetKeyboardState(&numkeys); |
| 117 | SDL_Scancode code = SDL_GetScancodeFromKey(key); | 123 | SDL_Scancode code = SDL_GetScancodeFromKey(key); |
| 118 | assert(code < numkeys); | 124 | assert(code < numkeys); |