public class Bat extends Animal
{
public void act()
{
move();
setLocation(getX(), getY()+1);
if(Greenfoot.isKeyDown("right")) setLocation(getX()+2, getY());
if(Greenfoot.isKeyDown("left")) setLocation(getX()-2, getY());
if(Greenfoot.isKeyDown("down")) setLocation(getX(), getY()+2);
if(Greenfoot.isKeyDown("up")) setLocation(getX(), getY()-3);
if(canSee(Heart.class)){
eat(Heart.class);
Greenfoot.playSound("heal.wav");
}
if(canSee(Human.class)){
eat(Human.class);
Greenfoot.playSound("suck.wav");
if (getObjects(Human.class).isEmpty()){
World brickWorld = getWorld();
GameOver gameover = new GameOver();
brickWorld.addObject(gameover, 190, 200);
Greenfoot.stop();
}
}
}
}