I was wondering how you could spawn objects in a certain way: so i want objects to spawn randomly all over the layout except a circle that follows my player so i avoid them spawning right over the player.
|...... O ....|
|_________| (ignore the dots)
so i tried "drawing" what i meant. i want object to spawn randomly in the rectangle (i know how to do that already) except the circle. So everywhere in the rectange but not the circle. the circle will be moving (following the player)
Thanks in advance!
Develop games in your browser. Powerful, performant & highly capable.
This may not be the most efficient method, but it works
Note: When using While like this you need to be aware of the danger of creating an infinite loop. If there is even a slight possibility that the correct x and y coordinates will never be found (say the safeRadius is too big), you should implement some way to terminate the loop. For example a counter - exit the loop if the counter reaches 100.