summaryrefslogtreecommitdiffstats
path: root/src/char/enemy.c
diff options
context:
space:
mode:
authorP. J. McDermott <pj@pehjota.net>2021-08-10 01:54:34 (EDT)
committer P. J. McDermott <pj@pehjota.net>2021-08-10 01:54:34 (EDT)
commit85494ad6865c9087b0d0f5a547b17042e7122662 (patch)
tree1f97a902929fb8c2c3d43280fde4e07aa9fdeaf9 /src/char/enemy.c
parent221523f82b2e4659db34f1fb1d8c180b3c442be3 (diff)
downloadmazefight-85494ad6865c9087b0d0f5a547b17042e7122662.zip
mazefight-85494ad6865c9087b0d0f5a547b17042e7122662.tar.gz
mazefight-85494ad6865c9087b0d0f5a547b17042e7122662.tar.bz2
char/enemy: Expose random positioning function
Diffstat (limited to 'src/char/enemy.c')
-rw-r--r--src/char/enemy.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/char/enemy.c b/src/char/enemy.c
index ca6d8e1..82cc16b 100644
--- a/src/char/enemy.c
+++ b/src/char/enemy.c
@@ -142,8 +142,7 @@ mf_enemy_new(struct mf_maze *maze, int cell_width, int maze_size)
while (c->cur_x < maze_size * MF_ENEMY_MIN_DIST &&
c->cur_y < maze_size * MF_ENEMY_MIN_DIST) {
- c->cur_x = rand() / (RAND_MAX / maze_size);
- c->cur_y = rand() / (RAND_MAX / maze_size);
+ mf_enemy_random_jump(c, maze_size);
}
c->cur_dir = MF_CHAR_DIR_N_;
@@ -152,3 +151,10 @@ mf_enemy_new(struct mf_maze *maze, int cell_width, int maze_size)
return c;
}
+
+void
+mf_enemy_random_jump(struct mf_char *c, int maze_size)
+{
+ c->cur_x = rand() / (RAND_MAX / maze_size);
+ c->cur_y = rand() / (RAND_MAX / maze_size);
+}