Hello,
I am working on a game where a ship avoids walls in 3D. I wanted to make sure the walls do not overlap in x values. Currently, they spawn in on a timed interval like so:
if (walls.size() <= max) {
// max is an int changed based off user's score
if (millis() - intialWallAddTime > wallAddInterval) {
intialWallAddTime = millis();
wallAddInterval= int(random(1000, 3000));
walls.add(new Wall(random(200, 1800), 100, 20));
}
}
for (Wall w : walls) {
w.render();
w.move();
}
The boxes come towards you, go off-screen, then are sent back to the top of the screen. And they usually end up overlapping and making the game easier and rough-looking. Is there any way to spawn them in with x values that are then removed from the next wall’s potential x values. Or each wall is tested to see if it will overlap.
Thanks.