From 85494ad6865c9087b0d0f5a547b17042e7122662 Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Tue, 10 Aug 2021 01:54:34 -0400 Subject: char/enemy: Expose random positioning function --- (limited to 'src/char') 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); +} -- cgit v0.9.1