-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNoob.js
More file actions
31 lines (26 loc) · 782 Bytes
/
Copy pathNoob.js
File metadata and controls
31 lines (26 loc) · 782 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
class Noob {
constructor(x, y, width, height, noobPos, noobAnimation) {
this.animation = noobAnimation;
this.speed = 0.05;
this.body = Bodies.rectangle(x, y, width, height);
this.width = width;
this.height = height;
this.noobPosition = noobPos;
World.add(world, this.body);
}
animate() {
this.speed += 0.05;
}
display() {
var angle = this.body.angle;
var pos = this.body.position;
var index = floor(this.speed % this.animation.length);
push();
translate(pos.x, pos.y);
rotate(angle);
imageMode(CENTER);
image(this.animation[index], 0, this.noobPosition, this.width, this.height);
noTint();
pop();
}
}