I am creating a game similar to space invaders, where ships (or in my case balloons) fall down to the bottom and you have to shoot them. I want to randomly spawn different colored balloons (signifying different strength). Simply put, the game is a combination of space invaders and bloons tower defense. Each 60 seconds, the level goes up, which makes the game harder. For the first 4 levels, a new colored balloon should be added into the mix every level. However, the 3rd level difficult and 4th level don't ever join in. I have checked the code and the first 2 levels look pretty much identical to 3 and 4 (with some exceptions to delay the entrance until the 3rd level). Here is a look at the yellow (which is coded in the MyWorld class):
public void yellow()
{
if(level==3)
{
yellowTimer++;
if(yellowTimer==270)
{
yellowRandom= Greenfoot.getRandomNumber(4);
if(yellowRandom==1)
{
addObject(new yellow(), Greenfoot.getRandomNumber(800),0);
}
if(yellowRandom==2)
{
addObject(new red(), Greenfoot.getRandomNumber(800),0);
addObject(new red(), Greenfoot.getRandomNumber(800),0);
}
yellowTimer=0;
}
}
}
I have quite a lot of code in the first page, and I don't want to post all of it here, so if you think you may have a fix, leave a comment and I can email you the entire file.