How can i make the end of my game attractive? Can I add some special effects?
final int w = getWorld().getWidth(), h=getWorld().getHeight();
for (int i=0; i<10; i++)
{
getWorld().addObject(new Balloon(), Greenfoot.getRandomNumber(w), h+20);
}/**direction: 0=straight up, -1=going left, -2=going left (slower), 1=going right, 2=going right (slower)*/
private final int direction = -2+Greenfoot.getRandomNumber(5);
/**timer: controls when the balloon has to go to the side*/
private int timer = 0;
public Balloon()
{
final int color = Greenfoot.getRandomNumber(4);
switch (color)
{
case 0: setImage("BalloonRed.png"); break;
case 1: setImage("BalloonYellow.png"); break;
case 2: setImage("BalloonBlue.png"); break;
case 3: setImage("BalloonGreen.png"); break;
}
}
public void act()
{
if (direction==0)
{
setLocation(getX(), getY()-1); //move straight up
}
else
{
int dx=0;
timer++;
if (timer>Math.abs(direction)*2)
{
if (direction>0) dx++;
else dx--;
timer=0;
}
setLocation(getX()+dx, getY()-1); //move up and to the side
}
}