summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorP. J. McDermott <pj@pehjota.net>2021-08-18 17:45:06 (EDT)
committer P. J. McDermott <pj@pehjota.net>2021-08-18 17:45:06 (EDT)
commit554f5cd43ab4adb794edbf7fc7beb8cc21029ac0 (patch)
treea584790fe6419fd9d43759d16d686ae4e2692dee
parentb1fbb0b1c078e82a651181101fed9d6742164e0b (diff)
downloadmazefight-554f5cd43ab4adb794edbf7fc7beb8cc21029ac0.zip
mazefight-554f5cd43ab4adb794edbf7fc7beb8cc21029ac0.tar.gz
mazefight-554f5cd43ab4adb794edbf7fc7beb8cc21029ac0.tar.bz2
char/enemy: Invert wall check logic
-rw-r--r--src/char/enemy.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/char/enemy.c b/src/char/enemy.c
index b981da7..a7a1251 100644
--- a/src/char/enemy.c
+++ b/src/char/enemy.c
@@ -85,11 +85,13 @@ _mf_enemy_step(struct mf_char *c)
case MF_CHAR_DIR_R_: dx = 1; dy = 0; break;
default: dx = 0; dy = 0; break;
}
- if (!mf_maze_is_wall(c->maze, c->cur_x, c->cur_y, dx, dy)) {
- /* Move */
- c->new_dir = dirs[i];
- return 0;
+ if (mf_maze_is_wall(c->maze, c->cur_x, c->cur_y, dx, dy)) {
+ /* Wall ahead; don't go this direction. */
+ continue;
}
+ /* Move */
+ c->new_dir = dirs[i];
+ return 0;
}
return 0;