hey guys i really need your help!
i'm totaly new in programming and i started with greenfoot it seems to be
easy to start with wombats :3
i want to spawn one coal-unit on the map(random place), but on the map is a hardcoded tree row..
if the coal-unit spawns randomly on one tree i want to remove the coal-unit and let the coal-unit spawn again
randomly until it spawns on a empty place.
and i want to spawn the coal unit 5px from the world edge, my world is 800x600
this is now where i stuck i dont get it how i can go one...
thaaanks
public class level_1 extends World
{
public level_1()
{
super(160, 120, 5);
spawn_coal();
spawn_treerow();
}
public void spawn_treerow()
{
addObject(new tree(), 12, 10);
addObject(new tree(), 31, 10);
addObject(new tree(), 50, 10);
}
public void spawn_coal()
{
addObject(new coal(), Greenfoot.getRandomNumber(getWidth()),Greenfoot.getRandomNumber(getHeight()));
}
}

