In my game my actor loses a life when hit by an opposing laser. This works, however a life is lost for every single pixel of my character that the laser passes through, resulting in my lives count reaching -200 in a single hit. How do I fix this?
Here's the relevant code for my Laser:
if (isTouching(Hakim.class))
{
World myWorld = getWorld();
MyWorld myworld = (MyWorld)myWorld;
Counter counter = myworld.getCounter();
counter.loseHealth(-1);
}
And here's the relevant code for my counter:
public void loseHealth(int amount)
{
health += amount;
setImage(new GreenfootImage("Lives : " + health, 24, Color.BLUE, Color.BLACK));
}
