I have a scenario where a car is required to drive round a racetrack.
I am required to add objects within the racetrack and when the car hits an object, it stops the game.
I'm stuck on adding random objects within the racetrack, I've figured out how to add random objects but sometimes they spawn outside of the racetrack, how can I combat this?
I'm guessing I need to check what the coordinates are for the racetrack and if it's found a coord within the track it needs to spawn the object and if it isn't, then it should loop back to the check, but I'm not sure how to add this in Java.
Any help would be great.

