summaryrefslogtreecommitdiff
path: root/src/zombies.c
diff options
context:
space:
mode:
authorAldrik Ramaekers <aldrik@amftech.nl>2024-01-07 18:57:07 +0100
committerAldrik Ramaekers <aldrik@amftech.nl>2024-01-07 18:57:07 +0100
commitc13e3bce702003aea65eef54ee462fd20cdf4fa1 (patch)
tree4e4821e4bfb73e2d3fae6c103bdc2a474fc63997 /src/zombies.c
parent89f6cc4d269f606157abf7824c5f385c7049082f (diff)
teehee
Diffstat (limited to 'src/zombies.c')
-rw-r--r--src/zombies.c7
1 files changed, 5 insertions, 2 deletions
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;