Hello, i am making a simple game where bugs eats leaf. But the game won't stop after the leaves were all eaten. I suspect the counter isn't working. here's the code
Superclass "Actors"
Subclass "Leaf"
help me please, i am a newbie here :)
import greenfoot.*;
/**
* Write a description of class Actors here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Actors extends Actor
{
int LeafEaten = 0;
/**
* Act - do whatever the Actors wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void getEaten()
{
Actor Bugs = getOneObjectAtOffset(0,0, Bugs.class);
if (Bugs != null)
getWorld().removeObject(this);
LeafEaten=LeafEaten + 1;
}
public void Touching()
{
Actor Lizard = getOneObjectAtOffset(0, 0, Bugs.class);
if (Lizard != null) Greenfoot.stop();
}
int i = Greenfoot.getRandomNumber(90);
public void LizardBounce()
{
turn(i);
getImage().mirrorVertically();
}
public void BugsTurn()
{
if(Greenfoot.isKeyDown("left"))
{
turn(-3);
}
if(Greenfoot.isKeyDown("right"))
{
turn(3);
}
}
public void gameOver()
{
{
if(LeafEaten==9)
Greenfoot.stop();
}
}
}import greenfoot.*;
/**
* Write a description of class Leaf here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Leaf extends Actors
{
/**
* Act - do whatever the Leaf wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
getEaten();
gameOver();
}
}


