import greenfoot.*; // (World, Actor, GreenfootImage, and Greenfoot)
/**
* A simple balloon that can move up and down.
*
* @author Av
*/
public class balloon extends Actor
{
public void explode()
{
if(getOneIntersectingObject(point.class) != null)
{
getWorld().addObject(new Explosion(), getX(), getY());
getWorld().removeObject(this);
}
}
public void act()
{
if (Greenfoot.isKeyDown("up") ) {
setLocation (getX(), getY() - 2);
}
if (Greenfoot.isKeyDown("down") )
{
setLocation (getX(), getY() + 2);
Actor coin;
coin = getOneObjectAtOffset(0,0, coin.class) ;
if (coin != null)
{
World world;
world = getWorld();
world.removeObject(coin);
}
}
}
}