-
Notifications
You must be signed in to change notification settings - Fork 0
/
dustbin.js
66 lines (55 loc) · 1.64 KB
/
dustbin.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
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
class dustbin
{
constructor(x,y)
{
this.x=x;
this.y=y;
this.dustbinWidth=200;
this.dustbinHeight=100;
this.wallThickness=20;
this.angle=0;
this.bottomBody=Bodies.rectangle(this.x, this.y, this.dustbinWidth, this.wallThickness, {isStatic:true})
this.leftWallBody=Bodies.rectangle(this.x-this.dustbinWidth/2, this.y-this.dustbinHeight/2, this.wallThickness, this.dustbinHeight, {isStatic:true})
Matter.Body.setAngle(this.leftWallBody, this.angle);
this.rightWallBody=Bodies.rectangle(this.x+this.dustbinWidth/2, this.y-this.dustbinHeight/2, this.wallThickness, this.dustbinHeight, {isStatic:true})
Matter.Body.setAngle(this.rightWallBody, -1*this.angle);
World.add(world, this.bottomBody)
World.add(world, this.leftWallBody)
World.add(world, this.rightWallBody);
}
display()
{
var posBottom=this.bottomBody.position;
var posLeft=this.leftWallBody.position;
var posRight=this.rightWallBody.position;
push()
translate(posLeft.x, posLeft.y);
rectMode(CENTER)
//strokeWeight(4);
angleMode(RADIANS)
fill(255)
stroke(255)
rotate(this.angle)
rect(0,0,this.wallThickness, this.dustbinHeight);
pop()
push()
translate(posRight.x, posRight.y);
rectMode(CENTER)
//strokeWeight(4);
stroke(255)
angleMode(RADIANS)
fill(255)
rotate(-1*this.angle)
rect(0,0,this.wallThickness, this.dustbinHeight);
pop()
push()
translate(posBottom.x, posBottom.y);
rectMode(CENTER)
//strokeWeight(4);
stroke(255)
angleMode(RADIANS)
fill(255)
rect(0,0,this.dustbinWidth, this.wallThickness);
pop()
}
}