-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstone.js
More file actions
28 lines (25 loc) · 682 Bytes
/
Copy pathstone.js
File metadata and controls
28 lines (25 loc) · 682 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
class Stone {
constructor(x, y, width, height){
var options = {
restitution: 0.9,
density: 1.2,
friction: 0.9
}
this.body = Bodies.polygon(x, y, 6, width/2, options);
World.add(world, this.body);
this.image = loadImage("hexagon.png");
this.width = width;
this.height = height;
}
display(){
var pos = this.body.position;
var angle = this.body.angle;
push();
translate(pos.x, pos.y);
rotate(angle);
rotate(100);
imageMode(CENTER);
image(this.image, 0, 0, this.width*1.28, this.height*1.28);
pop();
}
}