Jump to content


Photo

Filling a rectangle with instances


  • Please log in to reply
2 replies to this topic

#1 Jacepwns21

Jacepwns21

    GMC Member

  • GMC Member
  • 70 posts
  • Version:GM8

Posted 27 May 2012 - 08:01 AM

hello i am creating a level edtior and i need to know when i create a rectangle it fills it with instances plz answer this would be awesome to have
  • 0

#2 Jack Indie Box

Jack Indie Box

    GMC Member

  • GMC Member
  • 1489 posts
  • Version:GM:Studio

Posted 27 May 2012 - 09:26 AM

im gonna asume your rectangle is made from x1,y1,x2,y2

so you just have to xpos=clamp(xpos,x1,x2);
ypos=clamp(ypos,y1,y,2);
you need to do something to pick where u want it in the rectangle, this will just force it to be within

or
xpos=x+random_range(0,(x2-x1));
ypos=y+random_range(0,(y2-y1));
this should create the instances randomly in the rectangle.

if you want the instances to apear automatically you need to use a loop and put this in and instance_create(xpos,ypos,obj);
  • 0

#3 TheouAegis

TheouAegis

    GMC Member

  • GMC Member
  • 5216 posts
  • Version:GM8

Posted 27 May 2012 - 03:30 PM

And yet some part of me has this nagging fear he wants to use this information for something that could much more easily be done with tiles but will instead create a laggy game inundated with useless objects like most level editors. Oh well, I'll keep my fingers crossed until they cramp up.
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users