I'm trying to make a pacman game but my strawberries (that give you one extral life) don't work. Please help.
if (Greenfoot.getRandomNumber(1000) < 1)
{
getWorld().addObject( new strawberry(), 536, 204);
//there is a 0.01% that a strawberry will spawn at 536, 204
}
if (isTouching(strawberry.class))
{
lives = lives + 1;
removeTouching(strawberry.class);
//if pacman touches a strawberry increase his lives by one
}
if (lives == 0)
{
setImage("pacmandeath1.png");
Greenfoot.delay(4);
setImage("pacmandeath2.png");
Greenfoot.delay(4);
setImage("pacmandeath3.png");
Greenfoot.delay(4);
setImage("pacmandeath4.png");
Greenfoot.delay(4);
setImage("pacmandeath5.png");
Greenfoot.delay(4);
getWorld().removeObject(this);
//if lives = 0 then play death animation
}
getWorld().showText(Integer.toString(cherrytimer),524, 10);
//display pacman's lives at 524, 10
