-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathParticleSystem.pde
More file actions
54 lines (45 loc) · 781 Bytes
/
Copy pathParticleSystem.pde
File metadata and controls
54 lines (45 loc) · 781 Bytes
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
46
47
48
49
50
51
52
class ParticleSystem
{
ArrayList<Particle> particles;
PVector origin;
ParticleSystem(int num, PVector v)
{
particles = new ArrayList<Particle>();
origin = v.get();
for (int i = 0; i < num; i++)
{
addParticle();
}
}
void run()
{
Iterator<Particle> it = particles.iterator();
while (it.hasNext())
{
Particle p = it.next();
p.run();
if (p.isDead())
{
it.remove();
}
}
}
void addParticle()
{
particles.add(new Particle(origin));
}
void addParticle(Particle p)
{
particles.add(p);
}
boolean dead()
{
if (particles.isEmpty())
{
return true;
} else
{
return false;
}
}
}