-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbox.js
35 lines (33 loc) · 891 Bytes
/
box.js
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
class Box {
constructor(x, y) {
var options = {
'restitution':0.6,
'friction':1.0,
'density':0.6
}
this.body = Bodies.rectangle(x, y, 35, 50, options);
this.width = 35;
this.height = 50;
this.image = loadImage("sprites/box.png");
World.add(world, this.body);
}
display(){
if(this.body.speed < 11){
var angle = this.body.angle;
push();
translate(this.body.position.x, this.body.position.y);
rotate(angle);
imageMode(CENTER);
image(this.image, 0, 0, this.width, this.height);
pop();
}
if(this.body.speed > 11){
World.remove(world, this.body);
push();
this.Visibility = this.Visibility - 5;
tint(255,this.Visibility);
image(this.image, this.body.position.x, this.body.position.y, 50, 50);
pop();
}
}
};