diff options
| author | esquizo <esquizo+noreply@esquizo.net> | 2026-05-02 14:19:31 -0300 |
|---|---|---|
| committer | esquizo <esquizo+noreply@esquizo.net> | 2026-05-02 14:19:31 -0300 |
| commit | d2d0886cf770488d1b4890a3a414bbf983e784a6 (patch) | |
| tree | c6ee9e5c2e49aa7175236cfa6596355b16cb71af /sdl3_main.c | |
| parent | 34acd612061792a38aa13e376b20f4b5d4b54302 (diff) | |
desacoplado keys
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; } } } |
