import greenfoot.*;
/**
* Write a description of class Turtle here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class CaveMan extends Animals
{
private int lettuceEaten;
private int counter;
/**
* Act - do whatever the Turtle wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public CaveMan ()
{
lettuceEaten = 0;
counter= 0;
}
public void act()
{
move (3);
if ( Greenfoot.isKeyDown("left"))
{
turn(-5);
}
if ( Greenfoot.isKeyDown("right"))
{
turn(5);
}
if(isTouching(Burger.class))
{
removeTouching(Burger.class);
Greenfoot.playSound("slurp.wav");
lettuceEaten = lettuceEaten + 1;
if (lettuceEaten == 1)
{
setImage("winner.png");
setLocation (getX(), getY());
Greenfoot.playSound("fanfare.wav");
Greenfoot.stop();
}
}
}
}We never know if the win image will appear or if the lose image appears. When I commented out the setImage method it seemed more reliable. any thoughts on what might be the problem.
