void setup(){
jellies = new ArrayList();
for(int i=0; i<=5; i++){
jellies.add(new Jellyfish(random(0, 800), random(height), random(-40, 40), random(0.05, 0.35)));
}
for(int i = jellies.size()-1; i>=0; i–){
Jellyfish jellyfish = jellies.get(i);
jellyfish.display();
}
if(millis()-timer>=2000){
jellies.add(new Jellyfish(random(0, 800), 850, random(-40, 40), random(0.05, 0.35)));
timer=millis();
}
The above is just part of the code. I would like to display a new jellyfish coming from the bottom of the screen every 5 seconds. At first it works but after a while they start popping in the middle of the screen and stop completely.
Thanks!!