-
Notifications
You must be signed in to change notification settings - Fork 1
/
ParticleSystem.pde
47 lines (36 loc) · 762 Bytes
/
ParticleSystem.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
46
/* ========================
Particle System
======================== */
class ParticleSystem {
ArrayList<Particle> particles;
PShape particleShape;
ParticleSystem( int n ) {
particles = new ArrayList<Particle>();
particleShape = createShape( PShape.GROUP );
for ( int i = 0; i < n; i++ ) {
Particle p = new Particle();
particles.add( p );
particleShape.addChild( p.getShape() );
}
}
void update() {
for ( Particle p : particles ) {
p.update();
}
}
void setPos( float x, float y ) {
for ( Particle p : particles ) {
if ( p.isDead() ) {
p.rebirth( x, y );
}
}
}
void setSize( float size ) {
for ( Particle p : particles ) {
p.resize( size );
}
}
void display() {
shape( particleShape );
}
};