catch at edge of screen
This commit is contained in:
@@ -152,6 +152,15 @@ static long last_nsec = 0;
|
|||||||
|
|
||||||
#define NS_PER_TICK 30000000
|
#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)
|
void tick(void)
|
||||||
{
|
{
|
||||||
/* run every N milliseconds... nanoseconds? idk */
|
/* run every N milliseconds... nanoseconds? idk */
|
||||||
@@ -171,6 +180,7 @@ void tick(void)
|
|||||||
player_vy += player_ay;
|
player_vy += player_ay;
|
||||||
player_x += (int)player_vx;
|
player_x += (int)player_vx;
|
||||||
player_y += (int)player_vy;
|
player_y += (int)player_vy;
|
||||||
|
in_bounds();
|
||||||
draw_entities();
|
draw_entities();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user