I want the game to end when the health counter <= 0
ive gotten this far so far but I don't know what to put into the if statement
public void EndGame()
{
if ( totalHealthCount >= 0)
{
Greenfoot.stop();
Greenfoot.playSound("game-over.wav");
}
}
heres my health counter code;
Any help would be appreciated
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) import java.awt.Color; /** * Write a description of class Counter here. * * @author (ConorOwens) * @version (20/02/13) */ public class HealthCounter extends Actor { private int totalHealthCount = 100; public HealthCounter() { setImage(new GreenfootImage("" + totalHealthCount, 60, Color.WHITE, Color.BLACK)); } /** * Decrease the total amount displayed on the counter, by a given amount. */ public void bumpHealthCount(int amount) { totalHealthCount += amount; setImage(new GreenfootImage("" + totalHealthCount, 60, Color.WHITE, Color.BLACK)); } }