I am currently placing actors in a world which is a house. I want to place them in random locations as long as they are not a wall. Here's some of what I have so far:
However I suspect that if the random coordinates are on a wall it will do nothing. How can I modify the code so that the actor will continue to get random coordinates until it is not on a wall, or does this code already make sure of that?
Suspect suspect1 = new Suspect();
int num1 = getRandomNumber(1, 24);
int num2 = getRandomNumber(1, 24);
if(getWorld().getObjectsAt(getX()+dx, getY()+dy, Wall.class).isEmpty()){
addObject(suspect1, num1, num2);
}
Suspect suspect2 = new Suspect();
num1 = getRandomNumber(1, 24);
num2 = getRandomNumber(1, 24);
if(getWorld().getObjectsAt(getX()+dx, getY()+dy, Wall.class).isEmpty()){
addObject(suspect1, num1, num2);
}
