I want the Actors of Mole.class to not spawn on top or very close to my main actor Car.class . Therefore I think I need to create another if condition inside the color detection of the generated coordinates. The moles should spawn at least 50 pixels aways from my car. Any help is appreciated^^
To create my moles, I've got the following method:
public void createMoles()
{
while (getObjects(Mole.class).size() < 5)
{
int xPos = Greenfoot.getRandomNumber(1920);
int yPos = Greenfoot.getRandomNumber(1440);
int scrolledX = getScrolledX();
int scrolledY = getScrolledY();
Color color = getScrollingBackground().getColorAt(xPos, yPos);
if (color.getRed() == 77 && color.getGreen() == 77 && color.getBlue() == 77)
{
addObject(new Mole(), xPos-scrolledX-560, yPos-scrolledY-360);
}
}
}

