I am still very new to programming...so hopefully I can get some help here :)
I am now making a small game where you (Fish) want to eat Badfish. There is only 1 Badfish in the world at once, and when that one is eaten, a new one will spawn in a random spot. The thing is, I want the new one to spawn at least 100 pixels away from me (Fish).
I now already have a some codes that allow the Badfish to spawn randomly:
/**
* Whenever the Badfish has been eaten, a new one will randomly generated in the world
*/
private void createNewBadfish()
{
Badfish newBadfish;
newBadfish = new Badfish();
World world;
world = getWorld();
int worldWidth = world.getWidth();
int worldHeight = world.getHeight();
int x = Greenfoot.getRandomNumber(worldWidth);
int y = Greenfoot.getRandomNumber(worldHeight);
world.addObject(newBadfish, x, y);
}
