diff options
-rw-r--r-- | src/char.h | 9 | ||||
-rw-r--r-- | src/char/enemy.c | 10 |
2 files changed, 14 insertions, 5 deletions
@@ -35,9 +35,6 @@ void mf_char_get_vector(struct mf_char *c, int *x, int *y, int *travel, int *dx, int *dy); -void -mf_player_key_event(struct mf_char *c, SDL_Event *e); - int mf_char_update(struct mf_char *c); @@ -47,4 +44,10 @@ mf_char_render(struct mf_char *c, SDL_Renderer *renderer); void mf_char_destroy(struct mf_char **c_c); +void +mf_player_key_event(struct mf_char *c, SDL_Event *e); + +void +mf_enemy_random_jump(struct mf_char *c, int maze_size); + #endif /* MF_CHAR_H */ 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); +} |