public class Crab extends Actor
{
private int world;
/**
* Act - do whatever the Crab wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
move(2);
eat();
}
public void MoveandTurn()
{
if(Greenfoot .isKeyDown("left")) {
turn(6);
}
if(Greenfoot .isKeyDown("right")) {
turn(-6);
}
move(2);
}
public void eat()
{
Actor alligator;
alligator = getOneObjectAtOffset(0, 0, alligator.class);
if (alligator != null)
{
World World;
world = getWorld();
World.removeObject(alligator);
}
}
}
