diff --git a/main.c b/main.c index 7a998b4..77bdaca 100644 --- a/main.c +++ b/main.c @@ -62,6 +62,7 @@ static float player_vx = 0.0; static float player_vy = 0.0; static float player_ax = 0.0; static float player_ay = 9.81; +static int jump_ticks = 0; void key_down(char k) { @@ -71,7 +72,6 @@ void key_down(char k) { case 'a': player_ax = -1; break; case 'd': player_ax = 1; break; - case 0x20: player_ay -= 1; break; } } @@ -83,7 +83,6 @@ void key_up(char k) { case 'a': player_ax = 0; break; case 'd': player_ax = 0; break; - case 0x20: player_ay += 1; break; } } @@ -176,6 +175,8 @@ void tick(void) /* code to run every tick goes here */ erase_entities(); + if (is_held(' ')) player_ay = -5; + else player_ay = 9.81; player_vx += player_ax; player_vy += player_ay; player_x += (int)player_vx;