I have an assignment in which I have to make a fire works simulation using processing. My goal is to have a firework that can shoot out multiple ellipses in a circular formation. Image of what I'm trying to accomplish can be found here
The code I have right now seems to be drawing the ellipses in a spiral. I have copy-pasted my a download link for the code a the bottom, if anyone would like to try it out.
ArrayList<Ball> ballList;
int timer;
int amount;
int ball;
float angle;
boolean draws;
Ball b;
void setup() {
size(1300, 700);
ballList = new ArrayList<Ball>(ball);
ball= 36;
amount = 1000;
}
void draw() {
background(0);
for (int i = ballList.size()-1; i > -1; i--) {
for (int k = 0; k < ball; k++) {
Ball b = ballList.get(i);
fill(255, 0, 0, b.a);
b.display();
}// for loop
}// for loop
}// void draw
void mousePressed() {
for (int j = 0; j < ball; j++) {
ballList.add (new Ball(angle));
}
}
class Ball {
float X;
float Y;
float rad;
float mx;
float my;
float a;
float draw;
color c = color(random(0, 255), random(0, 255), random(0, 255));
float d;
float angle;
float X2;
float Y2;
float angle2;
float x;
float y;
Ball(float _angle) {
X = mouseX; //mouse X
Y = mouseY; //mouseY;
d = 0;
rad= 10;
angle = _angle;
a = 255;
}//Ball
void display() { // draw the ball and fill in colour
noStroke();
a--;
d++;
angle += 10;
if (angle >= 360) {
angle = 0;
}
angle2 = radians(angle);
X2 = cos(angle2) * d + X;
Y2 = sin(angle2) * d + Y;
a -= 0.5;
ellipse(X2, Y2, rad, rad);
}// void display
}