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

Get help using Construct 2

### » 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

### » 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 Classic - Examples Kit Dropbox is a pile of trash and if you need my old files PM me! :)
B
139
S
48
G
19
Posts: 2,268
Reputation: 22,165

### » 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