From c13e3bce702003aea65eef54ee462fd20cdf4fa1 Mon Sep 17 00:00:00 2001 From: Aldrik Ramaekers Date: Sun, 7 Jan 2024 18:57:07 +0100 Subject: teehee --- src/zombies.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/zombies.c') diff --git a/src/zombies.c b/src/zombies.c index 637d4dd..116b5fa 100644 --- a/src/zombies.c +++ b/src/zombies.c @@ -105,9 +105,12 @@ static vec2f get_random_target_for_zombie(zombie o) { vec2f target = {0,0}; try_again:; int dist = 10; - target.x = o.position.x + (rand() % dist) - (dist/2); - target.y = o.position.y + (rand() % dist) - (dist/2); + target.x = o.position.x + (rand() % dist) - (dist/2) +1; + target.y = o.position.y + (rand() % dist) - (dist/2) +1; + if (target.x <= 0 || target.y <= 0) goto try_again; + if (target.x >= MAP_SIZE_X-1 || target.y >= MAP_SIZE_Y-1) goto try_again; + object obj = get_object_at_tile(target.x, target.y); if (obj.active) goto try_again; -- cgit v1.2.3-70-g09d2