diff options
author | Juan J. Martinez <jjm@usebox.net> | 2023-07-22 13:58:05 +0100 |
---|---|---|
committer | Juan J. Martinez <jjm@usebox.net> | 2023-07-22 13:58:22 +0100 |
commit | 9ecd65467232071b18a7c6f782a22264046ebf45 (patch) | |
tree | 1a6110a495069900ac70b53d9d2746152aab1202 /src/player.c | |
parent | d6f7ac4c09ffb0717467790d9acc27df75e25b21 (diff) | |
download | gold-mine-run-9ecd65467232071b18a7c6f782a22264046ebf45.tar.gz gold-mine-run-9ecd65467232071b18a7c6f782a22264046ebf45.zip |
Joystick support
Diffstat (limited to 'src/player.c')
-rw-r--r-- | src/player.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/player.c b/src/player.c index 96fb283..28ad76e 100644 --- a/src/player.c +++ b/src/player.c @@ -1,6 +1,6 @@ #include <stdint.h> -#include "keyb.h" +#include "control.h" #include "vga.h" #include "sound.h" #include "map.h" @@ -133,6 +133,7 @@ static void player_dying() void player_update() { uint8_t moved = 0; + uint8_t ctl = CTL_NONE; ox = x; oy = y; @@ -143,6 +144,8 @@ void player_update() return; } + ctl = control_read(); + if (invuln) invuln--; @@ -158,7 +161,7 @@ void player_update() moved = 1; } - if (keys[KEY_UP]) + if (ctl & CTL_FIRE1) { if ((gravity == GRAVITY_OFF || momentum) && !jump) { @@ -172,7 +175,7 @@ void player_update() else jump = 0; - if (keys[KEY_RIGHT] && !keys[KEY_LEFT]) + if (ctl & CTL_RIGHT && !(ctl & CTL_LEFT)) { moved = 1; dir = DIR_RIGHT; @@ -192,7 +195,7 @@ void player_update() } } - if (keys[KEY_LEFT] && !keys[KEY_RIGHT]) + if (ctl & CTL_LEFT && !(ctl & CTL_RIGHT)) { moved = 1; dir = DIR_LEFT; |