0 Favourites

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

  • 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)

  • 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 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • 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

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic
99 10,137
karshinkoff's avatar
karshinkoff
Unread hot topic
167 14,497
DMT2005's avatar
DMT2005
Unread hot topic
123 14,869
Zebbi's avatar
Zebbi