• Hey! Guest! The 39th GMC Jam will take place between November 26th, 12:00 UTC and November 30th, 12:00 UTC. Why not join in! Click here to find out more!

GML Spawning off screen a group of objects?

M

makehurst

Guest
Hi all,

So I'm looking to spawn a group of object off screen that will slowly move onto screen. Once they get a point it will pick another group of objects and spawn them of screen and so on. Sort of like a endless runner.

I want to have control of where the object spawn setting up the groups.

The way I'm setting up the groups seems very sloppy at the minute and wanted to find out if there was a better way of doing it. At all I have is a big list that just says:

instance_create(0-1024, 736,obj_block)
instance_create(32-1024, 736,obj_block)
instance_create(32-1024, 704,obj_block)
instance_create(64-1024, 704,obj_block)
instance_create(64-1024, 672,obj_block)

and so on for about 150 lines. I really don't like this. Any one got any ideas?
 

Attachments

Tthecreator

Your Creator!
are you just randomly picking positions? You could use something like:
repeat(150){
instance_create(irandom(100)-1024, 736+irandom(100),obj_block)
}
 
M

makehurst

Guest
No I didn't want to randomly pick positions. I wanted to be able to set up each group that spawns. But I can see what your saying could work for randomly placing them.
 

Perseus

Not Medusa
Forum Staff
Moderator
A number of ways to make things less messy. An easy way would be to arrange the instance spawning code for different groups in different scripts. When a group of instances is to be spawned, choose a random script and use script_execute() to execute it.

Code:
var my_script = choose(scr_Pattern1, scr_Pattern2, scr_Pattern3 scr_Pattern4, ...);
script_execute(my_script);
There are numerous other ways to approach what you want, but I'd recommend not to over-complicate things. Keep it as simple as possible.
 
M

makehurst

Guest
Yeah I think you might be right on this one. Thanks for your help. Now to make loads of patterns with blocks.
 
Top