-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathParticleLeft.pde
More file actions
74 lines (50 loc) · 1.14 KB
/
Copy pathParticleLeft.pde
File metadata and controls
74 lines (50 loc) · 1.14 KB
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
class ParticleLeft{
PVector location;
PVector velocity;
PVector acceleration;
float lifespan;
float mass = 1;
// PImage particleImage;
int red = (int)random(50,250);
int green = 10;
int blue = (int)random(50,250);
ParticleLeft(PVector l){
acceleration = new PVector();
velocity = new PVector(random(4,3), random(-5.5,0));
location = l.get();
lifespan = 255;
}
void run(){
update();
display();
}
void update(){
velocity.add(acceleration);
location.add(velocity);
acceleration.mult(0);
lifespan-=2.5;
}
void display(){
float theta = map(location.x,0,width,0,TWO_PI * 2);
pushMatrix();
translate(location.x,location.y);
rotate(theta);
fill(red,green,blue,lifespan);
noStroke();
rect(0,0,8,8);
popMatrix();
}
boolean isDead(){
if(lifespan<0.0){
return true;
}
else{
return false;
}
}
void applyForce(PVector force){
PVector f = force.get();
f.div(mass);
acceleration.add(f);
}
}