summaryrefslogtreecommitdiffhomepage
path: root/src/enemies.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/enemies.c')
-rw-r--r--src/enemies.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/enemies.c b/src/enemies.c
index ad09e68..2640aae 100644
--- a/src/enemies.c
+++ b/src/enemies.c
@@ -262,10 +262,15 @@ random_enemy_create(
)
{
float spawn_coords[2];
+ cvec_collision_2d_world_item_value* p = get_player_position();
+ float player_coords[2] = {p->x, p->y};
+ float player_radius = p->height * 2 + 100;
for (int i = 0; i < 100; ++i) {
spawn_coords[0] = (float)rodeo_random_double_get() * bounds.width + bounds.x;
spawn_coords[1] = (float)rodeo_random_double_get() * bounds.height + bounds.y;
- if (!coords_inside_wall(spawn_coords[0], spawn_coords[1])) {
+ float dist = glm_vec2_distance(spawn_coords, player_coords);
+ if (!coords_inside_wall(spawn_coords[0], spawn_coords[1]) &&
+ dist > player_radius) {
return spawn_enemy(spawn_coords[0], spawn_coords[1]);
}
}