diff --git a/include/player.h b/include/player.h index 0d6861d..d7a67b7 100644 --- a/include/player.h +++ b/include/player.h @@ -1,4 +1,4 @@ -enum Direction; +enum { UP, DOWN, LEFT, RIGHT }; void jump_test(char *jump_pressed, char *jump_buffer, unsigned int *jump_hold, char enable_up_key); void set_start_pos(int *start_x, int *start_y, int x, int y); diff --git a/src/main.c b/src/main.c index ecfd341..8bf3f14 100644 --- a/src/main.c +++ b/src/main.c @@ -15,6 +15,13 @@ #define MIN_VSPD -12.0 #define MAX_VSPD 6.0 #define JUMP_SPD -3.99 +enum Direction +{ + up, + down, + left, + right +}; #define GRAV 0.4 #define JUMP_SCALE 8 #define JUMP_REDUCTION -0.41 @@ -59,6 +66,8 @@ int main(void) char exit_buffer = 0; char tp_buffer = 0; int tp_positions[4] = { 0, 0, 0, 0 }; + char directions[4] = { 0, 0, 0, 0 }; + char last_direction = RIGHT; set_level(level_id, level); DRAW_LEVEL(); player_x = start_x; @@ -80,6 +89,32 @@ int main(void) } //END DRAW clearevents(); + //direction inputs + if (keydown(KEY_LEFT)) + { + if (!directions[LEFT]) last_direction = LEFT; + directions[LEFT] += 1; + } + else directions[LEFT] = 0; + if (keydown(KEY_RIGHT)) + { + if (!directions[RIGHT]) last_direction = RIGHT; + directions[RIGHT] += 1; + } + else directions[RIGHT] = 0; + if (keydown(KEY_UP)) + { + if (!directions[UP]) last_direction = UP; + directions[UP] += 1; + } + else directions[UP] = 0; + if (keydown(KEY_DOWN)) + { + if (!directions[DOWN]) last_direction = DOWN; + directions[DOWN] += 1; + } + else directions[DOWN] = 0; + //direction inputs END //polarity swap first if (keydown(KEY_OPTN)) { diff --git a/src/player.c b/src/player.c index ea48d27..7f6538a 100644 --- a/src/player.c +++ b/src/player.c @@ -1,14 +1,6 @@ #include #include "player.h" -enum Direction -{ - up, - down, - left, - right -}; - void jump_test(char *jump_pressed, char *jump_buffer, unsigned int *jump_hold, char enable_up_key) {