I'm trying to make a game that is a baby sea turtle trying to get to the sea while avoid sea gulls. But I have no idea how to make seagulls (multiple at different sizes and spots) generate automatically at the right end of the screen and move towards the left and then disappear once they hit the worlds edge.
Any help is needed :/ it's for a project
This is my seagull class so far:
import greenfoot.*;
import greenfoot.*; // (World, Actor, GreenfootImage, and Greenfoot)
public class Seagull extends Objects
{
Counter counter;
public Seagull(Counter pointCounter)
{
counter = pointCounter;
}
public void act()
{
movement();
makeSeagull();
removeSeagull();
}
private void movement() {
int x = getX() - 5;
int y = getY();
setRotation(getRotation() + 0);
setLocation(x, y);
checkCollision();
}
public void makeSeagull()
{
World world = getWorld();
Seagull newSeagull = new Seagull(counter);
int worldHeight = world.getHeight();
int worldWidth = world.getWidth();
if(Greenfoot.getRandomNumber(9999) < 9)
{
world.addObject(newSeagull, worldWidth, Greenfoot.getRandomNumber(worldHeight));
}
}
public void removeSeagull()
{
World world = getWorld();
Seagull newSeagull = new Seagull(counter);
int worldHeight = world.getHeight();
int worldWidth = world.getWidth();
if(atWorldEdge()&& this != null)
{
world.removeObject(this);
//world.addObject(newSeagull, worldWidth, Greenfoot.getRandomNumber(worldHeight));
if(Greenfoot.getRandomNumber(9999) < 9)
world.addObject(newSeagull, worldWidth, Greenfoot.getRandomNumber(worldHeight));
}
}
public void checkCollision()
{
Actor a = getOneIntersectingObject(Turtle.class);
if (a != null)
{
Greenfoot.stop();
}
}
}

