link224444
Feb 16th, 2010, 02:09 PM
I am simply creating a script in game maker to make 3 objects appear each time you press a key such as space bar. The first time u press space 3 appear then 3 more appear 2nd time you hit it, so there will be 6 objects but i dont want them to touch, i checked there (x,y) but if the object had an (x,y) pos of (0,0) and the other had a (x,y) of (1,1) they have different positons so thats okay... How do i fix it so they dont touch at all?
var count as number;
var posx as number;
var posy as number;
// does this loop 3 times
for(count =1;count <= 3; count = count+1)
{
do
{
//finds random positon to place object
posx = random(room_width-32);
posy = random(room_height-32);
}
// keep looking if the (x,y) isnt available
until (place_free(posx,posy))
//Creats the object at that positon
instance_create(posx,posy,objcash);
}
var count as number;
var posx as number;
var posy as number;
// does this loop 3 times
for(count =1;count <= 3; count = count+1)
{
do
{
//finds random positon to place object
posx = random(room_width-32);
posy = random(room_height-32);
}
// keep looking if the (x,y) isnt available
until (place_free(posx,posy))
//Creats the object at that positon
instance_create(posx,posy,objcash);
}