Okay, I'm making a game where balloons slowly go across the screen (right-left). You have to shoot the balloons. Everything works (thank God). The only problemo is that I want the balloons to appear on the right side by themselves and then when they get to the end just leave. I want it to be an endless loop pretty much. I would prefer for them to be separated by probably just a random number between 1-3 seconds. can you please help me with the code?
Here is my balloon code so far.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class Ballon here. * * @author (your name) * @version (a version number or a date) */ public class Ballon extends Actor { /** * Act - do whatever the Ballon wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { move(- 4 ); if (Greenfoot.getRandomNumber( 100 )< 50 ) { setLocation(getX(),getY() + 5 ); } if (getX()< 10 ) { World world = getWorld(); world.removeObject( this ); } } } |