-
Notifications
You must be signed in to change notification settings - Fork 1
/
box.js
41 lines (37 loc) · 945 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
36
37
38
39
40
41
class Box{
constructor(x, y, width, height) {
var options = {
restitution :0.4,
friction :0.0,
//isStatic:true
}
this.visibility = 225;
this.body = Bodies.rectangle(x, y, width, height, options);
this.width = width;
this.height = height;
World.add(world, this.body);
}
score(){
if(this.visibility<0 && this.visibility >-105){
score++;
}
}
display(){
console.log(this.body.speed);
if(this.body.speed <3){
var angle = this.body.angle;
var pos= this.body.position;
push();
translate(pos.x, pos.y);
rotate(angle);
rectMode(CENTER);
rect(0,0,this.width, this.height);
pop();
}else{
World.remove(world, this.body);
push();
this.visibility = this.visibility -5;
pop();
}
}
}