var xx, yy, dis, num, list = ds_list_create(), iterations, obj = o_object, inst, start;
dis = 64; //gap between objects
xx = room_width/2;
yy = room_height/2;
inst = instance_create_depth(xx, yy, depth, obj);
inst.include = true;
iterations = ceil((sqrt(sqr(room_width/2) + sqr(room_height/2)))/dis)*2;
repeat(iterations) {
with(obj) {
if include {
start = random(360);
for (var i = 0; i < 360; i+=3) {
xx = x + lengthdir_x(dis, start + i);
yy = y + lengthdir_y(dis, start + i);
//check for a collision within a circular distance
num = collision_circle_list(xx, yy, dis, obj, false, true, list, false);
if num == 0 and xx > 0 and xx < room_width and yy > 0 and yy < room_height {
//no collision, create another
inst = instance_create_depth(xx, yy, depth, obj);
inst.include = true;
}
}
include = false; //remove this object from further checks
}
}
}
ds_list_destroy(list);