How do I prevent creating an object between certain coord's

Get help using Construct 2

Post » Sun Jun 29, 2014 5:07 pm

Basically I am making a game whereby objects spawn randomly on my layout (1280*720) but I have the "player" in the centre of this layout and I don't want any objects to spawn on it.

I am currently randomly spawning the objects using System --> Create Object --> random(5,1270), random(5,710)
B
6
Posts: 15
Reputation: 287

Post » Sun Jun 29, 2014 5:25 pm

you could try:

Create at:

X = choose(random(5, 630), random(650, 1270))
Y = choose(random(5, 350), random(370, 710))

I don't know how well that will work, but what it's basically doing is:

Choose () = pick a random option from list of options

so for X: spawn on left side of player, or right side of player (assuming player is at center 640, 360) and about 10 pixels away from exact center

then for Y: spawn on top or bottom side of player
"Construct 4 lets YOU make advanced games! (but not play them)" Construct Classic - Examples Kit Dropbox is a pile of trash and if you need my old files PM me! :)
B
121
S
42
G
17
Posts: 2,219
Reputation: 19,800

Post » Sun Jun 29, 2014 8:00 pm

Jayjay wrote:you could try:

Create at:

X = choose(random(5, 630), random(650, 1270))
Y = choose(random(5, 350), random(370, 710))

I don't know how well that will work, but what it's basically doing is:

Choose () = pick a random option from list of options

so for X: spawn on left side of player, or right side of player (assuming player is at center 640, 360) and about 10 pixels away from exact center

then for Y: spawn on top or bottom side of player


Thank you! Didn't realise you could set 2 conditions for each coord
B
6
Posts: 15
Reputation: 287


Return to How do I....?

Who is online

Users browsing this forum: 25games and 28 guests