catch at edge of screen

This commit is contained in:
Tobin
2026-04-19 16:37:40 -04:00
parent 52bda0b5f4
commit c5f584fd13
+10
View File
@@ -152,6 +152,15 @@ static long last_nsec = 0;
#define NS_PER_TICK 30000000
/* FIXME this is just temporary */
void in_bounds(void)
{
if (player_x < 0) player_x = 0;
if (player_y < 0) player_y = 0;
if (player_x > screen_width - 50) player_x = screen_width - 50;
if (player_y > screen_height- 50) player_y = screen_height - 50;
}
void tick(void)
{
/* run every N milliseconds... nanoseconds? idk */
@@ -171,6 +180,7 @@ void tick(void)
player_vy += player_ay;
player_x += (int)player_vx;
player_y += (int)player_vy;
in_bounds();
draw_entities();
}