Random spawn help

Get help using Construct 2

Post » Thu Jan 05, 2012 1:29 pm

Okay I've been trying to look around the forum for help, even the FAQ but no luck. Well my problem is that I am making a survival zombie game. Think like the turorial where there are ghosts, like that but with zombies and I want my zombies to spawn randomly on the layout.

And I can guess that it's possible that if my score is x then spawn a new type of zombies. If you can then please help me.
B
8
S
3
G
2
Posts: 101
Reputation: 2,065

Post » Thu Jan 05, 2012 1:40 pm

If you have no restrictions on where the should spawn it's fairly easy. Use random to create a X and a Y value within the borders of your layout. Then you can utilize the "System - Create Object" with these values to spawn your Zombies.
B
42
S
19
G
12
Posts: 723
Reputation: 13,911

Post » Thu Mar 29, 2012 10:06 pm

where is the reference manual for using things like random()
B
7
S
1
Posts: 65
Reputation: 821

Post » Thu Mar 29, 2012 10:18 pm

@rafhelp: it's the system expressions in the system references.
You can also have a look at the system conditions and actions.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,999
Reputation: 57,793

Post » Sun Apr 15, 2012 10:56 am

[QUOTE=Weishaupt] If you have no restrictions on where the should spawn it's fairly easy. Use random to create a X and a Y value within the borders of your layout. Then you can utilize the "System - Create Object" with these values to spawn your Zombies.[/QUOTE]

I am really new to construct 2 and very new to programming..when you say "Use random to create a X and a Y value within the borders of your layout" what exactly needs to be done on the event sheet ??
B
7
Posts: 28
Reputation: 781

Post » Sun Apr 15, 2012 11:20 am

Have a trigger, such as time, score etc.

Then - System -> Create Object (which is right at the top)

Choose a layer and then input and X and a Y value. X and Y being a pixel value corresponding to the playing area. Just say your layout size is 1280 by 1024 (you can check this by clicking on your layout in the Projects Bar), the enter a number between 0 and 1280 for X and 0 and 1024 for Y.

Instead of entering a number, you can use the "random" expression to make it generate a random number. In which case enter random(0,1281) in the X section, and random(0,1025) in the Y section of the Create Object event. The random() expression will return a random number between the two numbers you enter. Well actually, it will return a value between and including the first number, and one less than the second number, hence why I added 1 to the last number of those examples.Puck2012-04-16 01:26:14
B
32
G
1
Posts: 18
Reputation: 1,663

Post » Sun Apr 15, 2012 11:46 am

thank you so much..that at least helped me to get started with placing the objects randomly in my game.. is there anyway i can control the number of objects spwan when the player is in the game screen...i am making a 2d..free run...survival side scroller..
B
7
Posts: 28
Reputation: 781


Return to How do I....?

Who is online

Users browsing this forum: Bad Wolf, davides, NRABrazil, Vallar, Walessio and 27 guests