public class hp extends Actor
{
/**
* Act - do whatever the hp wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public int hp = 100;
public hp()
{
update();
}
public void act()
{
while(Greenfoot.isKeyDown("enter")){
hp = hp - 10;
update();
}
}
public int getHp(){
return hp;
}
public void update()
{
setImage(new GreenfootImage("Health: "+hp, 18, Color.BLACK, Color.GREEN));
}
}
