import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Terrorist here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Duck extends Actor
{
private int i;
public int life;
/**
* Act - do whatever the Terrorist wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public Duck()
{
//getWorld().showText("Health: " + health, 100, 100);
}
public void act()
{
Moving();
Damage();
}
public void Moving()
{
if(getY() == 400)
{
while (i < 30)
{
setLocation(getX()-1, getY());
i++;
}
}
}
public void Damage()
{
int number = getWorld().numberOfObjects();
if(Greenfoot.getRandomNumber(7000) < number)
{
getWorld().addObject(new Damage(), 500, 250);
life--;
getWorld().showText("Health: " + life, 100, 100);
}
}
}
