so what im trying to do is spawn a ball with some attributes and after 5 seconds i want to create spawn another one of this balls up untill 7 but im not sure how to “add” new ball to the array with the same attributes that i set up in the “setup” section ill include the part of the code:
Ellipse[] ball = new Ellipse[1];
int savedTime;
int timerTime = 5000;
void setup() {for (int i=0; i<ball.length; i++){
ball[i] = new Ellipse();
ball[i].radiusX=25;
ball[i].radiusY=25;
ball[i].x=width/2-ball[i].radiusX;
ball[i].y=height/2-ball[i].radiusY;
ball[i].brush=color(255, 0, 0);
ball[i].direction=int(random(0,359));
ball[i].brush = color(255,165,0);
ball[i].pen = color(0,0,0);
ball[i].penThickness = 3;
ball[i].speed=5;
}
}
void draw() {
int passedTime = millis() - savedTime;
for(int i =0;i<ball.length;i++){
//here im doing some actions on the ball itself i dont think it metters for that question so i wont include it 🙂
if(passedTime>timerTime){
ball = new Ellipse[i++];
savedTime = millis();
}
ball[i].draw();
}