I have a project in which I need to make a bomb emit smoke and then explode. In the world class, I have this:
The idea here is that it spawns smoke 5000 times, with a 1/4 second pause between each one, before spawning 10 fires all at once, and then stopping. However, when I run the code, it creates one smoke particle and 10 fires all at once and then instantly stops. I'm not sure what's going wrong here.
public void act()
{
for (int i = 0; i < 5000; i++)
{
long currentTime = System.currentTimeMillis();
if (currentTime >= Wait + 25) //25ms = 1/4 second
{
Smoke smoke = new Smoke(Greenfoot.getRandomNumber(15) + 340,Greenfoot.getRandomNumber(9) + 1);
addObject(smoke,280,170);
Wait = currentTime;
}
}
for (int i = 0; i < 10; i++)
{
Fire fire = new Fire(Greenfoot.getRandomNumber(360),10);
addObject(fire,255,235);
}
Greenfoot.stop();
}
