-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWalker.js
More file actions
49 lines (33 loc) · 847 Bytes
/
Copy pathWalker.js
File metadata and controls
49 lines (33 loc) · 847 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
class Walker {
constructor() {
this.pos = createVector(mouseX, mouseY);
this.vel = createVector(random(-9,9), (0-mouseY)*0.05);
this.acc = createVector(0, (mouseY - height) * -0.003);
this.w = 30;
this.t = 0;
this.op = 250;
}
update() {
this.vel.add(this.acc);
this.vel.mult(0.99);
// this.vel.mult(height - mouseY);
this.pos.add(this.vel);
}
checkEdges() {
if (this.pos.x > width || this.pos.x < 0 ) {
this.vel.x *= -1;
}
if (this.pos.y > height || this.pos.y < 0 ) {
if (this.pos.y > height){
this.pos.y = height;
}
this.vel.y *= -0.9;
this.op = this.op -1;
}
}
display() {
fill(255,180,55,this.op );
stroke(0,this.op);
ellipse(this.pos.x, this.pos.y, this.w);
}
}