Hi
I am working with Frogger for school, and I need a live counter. I came far, but I don't know how to make the lives go down or up.
Please help me.
import greenfoot.*; import java.awt.Color; public class Lifeboard extends Actor { int lives = 3; public Lifeboard() { updateBoard(); } private void updateBoard() { setImage(new GreenfootImage("Lives remaining: " + lives, 20, Color.black, new Color(0, 0, 0, 0))); } public void add(int addVal) { if (lives == 0 && addVal == -1) { // ^ (lost a life and no lives remaining) // play sound, showGameOver/Final score // whatever you want to do for ending game Greenfoot.stop(); return; } lives += addVal; updateBoard(); } public int getLivesLeft() { return lives; } public void livesDown(){ lives = lives -1; if( lives == 0){ Greenfoot.stop(); return; } } }