-
Notifications
You must be signed in to change notification settings - Fork 0
/
Particalsystem.pde
45 lines (39 loc) · 917 Bytes
/
Particalsystem.pde
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
class Firework {
ArrayList<Particle> particles;
Particle firework;
float hu;
Firework() {
hu = random(270, 330);
firework = new Particle(random(width), height, hu);
particles = new ArrayList<Particle>();
}
boolean done() {
if (firework == null && particles.isEmpty()) {
return true;
} else {
return false;
}
}
void run() {
if (firework != null) {
fill(hu, 255, 255);
firework.applyForce(gravity);
firework.update();
firework.display();
if (firework.explode()) {
for (int i = 0; i < 100; i++) {
particles.add(new Particle(firework.location, hu));
}
firework = null;
}
}
for (int i = particles.size() - 1; i >= 0; i--) {
Particle p = particles.get(i);
p.applyForce(gravity);
p.run();
if (p.isDead()) {
particles.remove(i);
}
}
}
}