Hello, I want to make it so when I eat a balloon it then adds a skull. How do I do that?
Here is my code so far:
import greenfoot.*;
/**
* Write a description of class robot here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class robot extends Actor
{
private int balloonEaten = 0;
private Counter counter;
private skull skull;
public robot(Counter pointCounter)
{
counter = pointCounter;
}
public void act()
{
if (Greenfoot.isKeyDown("right"))
move(5);
if (Greenfoot.isKeyDown("left"))
move(-5);
if (Greenfoot.isKeyDown("space"))
turn(17);
setRotation(90);
if (Greenfoot.isKeyDown("up"))
{ move(-5); }
if (Greenfoot.isKeyDown("down"))
{ move(5); }
setRotation(0);
if (isAtEdge() )
{
turn(90);
}
Actor balloon = getOneIntersectingObject(balloon.class);
if(balloon != null)
{
World myWorld = getWorld();
balloonEaten++;
counter.add(1);
Greenfoot.playSound("balloon pop.mp3");
myWorld.removeObject(balloon);
if (counter.getValue() >= 9) {
gameOver();
}
if (balloonEaten >= 10) {
YouWin youwin = new YouWin();
myWorld.addObject(youwin, myWorld.getWidth()/2, myWorld.getHeight()/2);
}
}
}
/**
* We have won the game.
*/
public void gameOver()
{
Greenfoot.playSound("superstition.wav");
Greenfoot.stop();
}
}


