The Daily Click ::. Forums ::. Klik Coding Help ::. silly random question
 

Post Reply  Post Oekaki 
 

Posted By Message

Santa



Registered
  19/05/2003
Points
  644
18th August, 2003 at 14:14:42 -

Heres what i wanna do, i wanna make a qrid of a altrable size, then place a set number of objects onto the grid.

To do this i made a block 20 * 20 (same size as the squares on my grid) at 0,0 then i set the x pos to Random(gridwidth)*20 and same for the y pos. Then i created another object over top of the test block, then repositioned the test block and did the same again.

I told it to do it until the amount of objects reached a set amount. Sadly the objects sometimes overlapped so you couldnt actually see the amount of objects i should be able to see.

So i then added a line that deleted them if they were overlapping.

Sometimes it took almost forever to make the objects because it spent so long deleting em and making em again.

Someone has to know a better way to do this, perhaps using a array???

Please help thiss is important

ThanXs - SAnTA

 
SAnTA - www.atnas.com

-------------------
www.create-games.com/download.asp?id=2918

Dogzer



Registered
  07/02/2011
Points
  1029
18th August, 2003 at 14:46:26 -

omg "grid"! *stops reading question* start with something simple... like a square that moves to the left only.. yeah.. simple WOHOO!!!! ok bye

 
n/a

Shen

Possibly Insane

Registered
  14/05/2002
Points
  3497
18th August, 2003 at 15:31:35 -

omg dogzer! *bans*

You could do it if an object is overlapping another object, pick one of them and destroy it. I think.



 
gone fishin'

Activ8games



Registered
  02/07/2003
Points
  463
18th August, 2003 at 15:35:56 -

To make a grid, you could try fastloops.

In the event editor do:

Start of frame (or whatever it is):
---start loop y (number of grid cells going down) times

ON loop "y"
---start loop x (number of cells going across) times

On loop "x"
---set x co-ordinate of object to loopstep("x")*20
---set y co-ordinate of object to loopstep("y")*20
---paste object in background

To change the size, you just need to change the amount of times the loops occur.

If you want to ge the number of objects just add to a counter every time the loop x occurs.

Oh yeah, there is also some grid extensions available but I'm not sure about those.
Hope this helps

Image Edited by the Author.

 
Vote Quimby!!!

Jenswa

Possibly Insane

Registered
  26/08/2002
Points
  2723
18th August, 2003 at 15:51:12 -

But that's not random, i thought he wanted it to be random,

i don't know what you exactly want,
but can't you move x or y 20 pixels, if the blocks
are overlapping.
Should for a block, but multiple block in a click-product, might not understand it.

 
Image jenswa.neocities.org

Assault Andy

Administrator
I make other people create vaporware

Registered
  29/07/2002
Points
  5686

Game of the Week WinnerVIP Member360 OwnerGOTM JUNE - 2009 - WINNER!GOTM FEB - 2010 - WINNER!	I donated an open source project
19th August, 2003 at 05:15:54 -

You should use an array for this, then if there is nothing in a certain slot, allow something to be created there.

-Andy

 
Creator of Faerie Solitaire:
http://www.create-games.com/download.asp?id=7792
Also creator of ZDay20 and Dungeon Dash.
http://www.Jigxor.com
http://twitter.com/JigxorAndy

Shen

Possibly Insane

Registered
  14/05/2002
Points
  3497
19th August, 2003 at 12:41:27 -

Or you could make a new one every 20 pixels, and move it to a random Y position * 20.

 
gone fishin'

Santa



Registered
  19/05/2003
Points
  644
21st August, 2003 at 03:26:04 -

OK, i got this to work kinda, i used fastloops to create a object in every square (In the same way i create the grid) Then i select them at random and delete them until their is only a set number left.

The whole thing takes about 2 seconds to draw. Would be better if i could make it faster but still... this does the job.

 
SAnTA - www.atnas.com

-------------------
www.create-games.com/download.asp?id=2918

Assault Andy

Administrator
I make other people create vaporware

Registered
  29/07/2002
Points
  5686

Game of the Week WinnerVIP Member360 OwnerGOTM JUNE - 2009 - WINNER!GOTM FEB - 2010 - WINNER!	I donated an open source project
21st August, 2003 at 03:33:43 -

Couldn't you just make the grid a background?

-Andy

 
Creator of Faerie Solitaire:
http://www.create-games.com/download.asp?id=7792
Also creator of ZDay20 and Dungeon Dash.
http://www.Jigxor.com
http://twitter.com/JigxorAndy
   

Post Reply



 



Advertisement

Worth A Click