Main code:
public class Binary extends Actor
{
public static int explode = 0;
/**
* Act - do whatever the Binary wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
if(explode >= 3)
{
Greenfoot.stop();
}
}
}
Code in one actor
public void act()
{
//
if (getY() < getWorld().getHeight() - 80)
{
setLocation(getX(), getY() + 2);
}
else
{
setImage("Mushroom.png");
explode=explode+1;
}
Code in second actor
public void act()
{
//
if (getY() < getWorld().getHeight() - 80)
{
setLocation(getX(), getY() + 2);
}
else
{
setImage("Mushroom.png");
explode=explode+1;
}
When both of these add up to 3, I want the game to end. I am not sure how to do that though.