public class Alien extends Actor
{
/**
* Act - do whatever the Alien wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
setLocation(getX(),getY()+(Greenfoot.getRandomNumber(10)-Greenfoot.getRandomNumber(8))); //This line of code is what controls the speed of the Alien as it moves down
//It is also responsible for the random motion that occurrs as it moves down.
onTheEdge();
}
/**
* This part is a test to see whether the alien is on the edge.
* If the Alien is on the edge, it is removed from the world.
*
*/
public void onTheEdge()
{
if (isAtEdge())
{
getWorld().removeObject(this);
getWorld().addObject(new Alien(),(Greenfoot.getRandomNumber(791)+5),70);
}
}
}
