The Daily Click ::. Forums ::. Klik Coding Help ::. Creating a large group of objects at once
 

Post Reply  Post Oekaki 
 

Posted By Message

noahsummers



Registered
  17/01/2010
Points
  64
11th February, 2010 at 17:07:28 -

For my Breakout game, I want to have the next set of bricks spawn above the screen and scroll down after the player has passed a level. However, this will require me to set a creation event for every single brick (approximately 100 per level), for every single level. Is there an extension or an alternative method of object creation that would allow me to create a "grid-full" of objects at once, or something to that effect?

 
eight bit believer

UrbanMonk

BRING BACK MITCH

Registered
  07/07/2008
Points
  49667

Has Donated, Thank You!Little Pirate!ARGH SignKliktober Special Award TagPicture Me This Round 33 Winner!The Outlaw!VIP MemberHasslevania 2!I am an April FoolKitty
Picture Me This Round 32 Winner!Picture Me This Round 42 Winner!Picture Me This Round 44 Winner!Picture Me This Round 53 Winner!
11th February, 2010 at 18:08:13 -

Using loops.

On new level-
-Start loop "createlevel" 50

On loop "createlevel"-
-Create object "brick"
-Set x pos of "brick" (loopindex("createlevel")*20)-((loopindex("createlevel")/10)*200)
-Set y pos of "brick" (loopindex("createlevel")/10)*20


This is just an example, but that is basically how it's done.
The code above will create a 10 x 5 array of brick objects spaced 20 pixels apart.


 
n/a

OMC

What a goofball

Registered
  21/05/2007
Points
  3516

KlikCast Musician! Guy with a HatSomewhat CrazyARGH SignLikes TDCHas Donated, Thank You!Retired Admin
11th February, 2010 at 18:14:29 -

If you want it to vary, store their positions in an array or list and use a fastloop, as UrbanMonk suggested.

Start of new level:
Load list "whatever."
+Start loop "bricks" (number of lines in list) times.

On loop "bricks":
Create brick offscreen.
+Set X and Y positions to current line of list. (Use the string parser and a delimiter to separate the values. If you don't know what this means, I can explain it.)
+Set list to next line.

Should probably work. You'd either have to make an application to store brick positions in a list, or enter the coordinates manually.

Edited by OMC

 

  		
  		

noahsummers



Registered
  17/01/2010
Points
  64
12th February, 2010 at 00:10:52 -

Thanks for the help!

 
eight bit believer
   

Post Reply



 



Advertisement

Worth A Click