diff options
Diffstat (limited to 'src/char')
-rw-r--r-- | src/char/enemy.c | 10 |
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); +} |