import greenfoot.*;
public class coal extends Actor
{
public void spawn_coal()
{
boolean spawned = false;
while(!spawned) {
int x = 5 + Greenfoot.getRandomNumber(getWidth()-10);
int y = 5 + Greenfoot.getRandomNumber(getHeight()-10);
coal myCoal = new coal();
addObject(myCoal, x , y);
spawned = true;
}
if(myCoal.getIntersectingObjects(tree.class) != null) {
removeObject(myCoal);
spawned = false;
}
}
}
