-
Notifications
You must be signed in to change notification settings - Fork 0
/
Eid.pde
75 lines (63 loc) · 1.24 KB
/
Eid.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
class Particle {
PVector location;
PVector velocity;
PVector acceleration;
float lifespan;
boolean seed = false;
float hu;
Particle(float x, float y, float h) {
hu = h;
acceleration = new PVector(0, 0);
velocity = new PVector(0, random(-20, -10));
location = new PVector(x, y);
seed = true;
lifespan = 255.0;
}
Particle(PVector l, float h) {
hu = h;
acceleration = new PVector(0, 0);
velocity = PVector.random2D();
velocity.mult(random(4, 8));
location = l.copy();
lifespan = 255.0;
}
void applyForce(PVector force) {
acceleration.add(force);
}
void run() {
update();
display();
}
boolean explode() {
if (seed && velocity.y > 0) {
lifespan = 0;
return true;
}
return false;
}
void update() {
velocity.add(acceleration);
location.add(velocity);
if (!seed) {
lifespan -= 5.0;
velocity.mult(0.95);
}
acceleration.mult(0);
}
void display() {
stroke(hu, 255, 255, lifespan);
if (seed) {
strokeWeight(4);
} else {
strokeWeight(2);
}
point(location.x, location.y);
}
boolean isDead() {
if (lifespan < 0.0) {
return true;
} else {
return false;
}
}
}