rough friction

This commit is contained in:
Tobin
2026-04-20 13:48:11 -04:00
parent 2753355756
commit 4d469695bb
+11 -2
View File
@@ -70,8 +70,8 @@ void key_down(char k)
printf("%c pressed!\n", k); printf("%c pressed!\n", k);
switch (k) switch (k)
{ {
case 'a': player_ax = -1; break; case 'a': player_ax = -2; break;
case 'd': player_ax = 1; break; case 'd': player_ax = 2; break;
} }
} }
@@ -160,6 +160,14 @@ void in_bounds(void)
if (player_y > screen_height- 50) player_y = screen_height - 50; if (player_y > screen_height- 50) player_y = screen_height - 50;
} }
void apply_friction(void) /* FIXME */
{
if (player_vx > 0) player_vx -= 1;
else if (player_vx < 0) player_vx += 1;
if (player_vy > 0) player_vy -= 1;
else if (player_vy < 0) player_vy += 1;
}
void tick(void) void tick(void)
{ {
/* run every N milliseconds... nanoseconds? idk */ /* run every N milliseconds... nanoseconds? idk */
@@ -179,6 +187,7 @@ void tick(void)
else player_ay = 9.81; else player_ay = 9.81;
player_vx += player_ax; player_vx += player_ax;
player_vy += player_ay; player_vy += player_ay;
apply_friction(); /* FIXME */
player_x += (int)player_vx; player_x += (int)player_vx;
player_y += (int)player_vy; player_y += (int)player_vy;
in_bounds(); in_bounds();