diff options
Diffstat (limited to 'sdl3_main.c')
| -rw-r--r-- | sdl3_main.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/sdl3_main.c b/sdl3_main.c index 709a37c..701dfe4 100644 --- a/sdl3_main.c +++ b/sdl3_main.c @@ -17,6 +17,7 @@ static Uint64 old_ticks, new_ticks; static float camera_x, camera_y; bool shot; +bool moveup, movedown, moveleft, moveright; int shotx, shoty; int @@ -159,6 +160,20 @@ process_events() shotx = event.button.x + camera_x; shoty = event.button.y + camera_y; break; + + case SDL_EVENT_KEY_UP: + case SDL_EVENT_KEY_DOWN: + #define DEFINE_KEY(X, VAR) \ + if(event.key.scancode == X) VAR = event.type == SDL_EVENT_KEY_DOWN + + DEFINE_KEY(SDL_SCANCODE_W, moveup); + DEFINE_KEY(SDL_SCANCODE_A, moveleft); + DEFINE_KEY(SDL_SCANCODE_S, movedown); + DEFINE_KEY(SDL_SCANCODE_D, moveright); + + #undef DEFINE_KEY + + break; } } } |
