-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathParticle.pde
58 lines (50 loc) · 997 Bytes
/
Particle.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
47
48
49
50
51
52
53
54
55
56
57
58
class Particle {
PVector location;
PVector velocity;
PVector acceleration;
int angry =0;
float lifespan;
Particle(PVector l, int a) {
acceleration = new PVector(0, 0.5);
velocity = new PVector(random(-1, 1), random(-1, 1));
location = l.get();
lifespan =255.0;
angry=a;
}
Particle(PVector l) {
acceleration = new PVector(0, 0.5);
velocity = new PVector(random(-1, 1), random(-1, 1));
location = l.get();
lifespan =255.0;
}
void run() {
update();
display();
}
void update() {
velocity.add(acceleration);
location.add(velocity);
if(location.x>=width){
}
lifespan-=1.0;
}
void display() {
stroke(255, lifespan);
fill (255, lifespan);
ellipse(location.x, location.y, 8, 8);
}
boolean isDead() {
if (lifespan<0.0) {
return true;
} else {
return false;
}
}
void isAngry(){
if(angry==1){
return true;
}else{
return false
}
}
}