i wrote a command for greenfoot to stop after the crab has no lives but it is stopping at the beginning of the game. what is wrong? here is my code for the lobster (that eats the crab and causes it to lose a life).
if i take out the last part then the game works just fine, however i need it to stop when the counter = 0
import greenfoot.*; public class Lobster extends Animals { private SimpleCounter simpleCounter; public Lobster(SimpleCounter lifeCounter) { simpleCounter = lifeCounter; } public void act() { moveAround(); eatCrab(); } private void moveAround() { move(5); if (Greenfoot.getRandomNumber (100) < 10) { turn(Greenfoot.getRandomNumber (90)-45); } if (atWorldEdge()) { turn(180); } } public boolean atWorldEdge() { if (getX() <= 5 || getX() >= getWorld() . getWidth() -5 || getY() <= 5 || getY() >= getWorld() . getHeight() -5) return true; return false; } private void eatCrab() { Actor crab; crab = (Crab)getOneObjectAtOffset (0,0,Crab.class); if (crab != null) { int x = Greenfoot.getRandomNumber(getWorld().getWidth()); int y = Greenfoot.getRandomNumber(getWorld().getHeight()); crab.setLocation(x, y); getImage().scale(getImage().getWidth()*110/100, getImage().getHeight()*110/100); simpleCounter.subtract(1); Greenfoot.playSound ("eating.wav"); } if (simpleCounter.getValue() == 0); { Greenfoot.stop(); } } }