Angry Birds
(Part 2)
Log.js:
class Log {
constructor(x, y, h, angle) {
var options = {
restitution: 0.3,
friction: 4,
density: 1.0,
};
this.body = Bodies.rectangle(x, y, 20, h, options);
this.width = 20;
this.height = h;
Matter.Body.setAngle(this.body, angle);
World.add(world, this.body);
}
display() {
var pos = this.body.position;
var angle = this.body.angle;
push();
translate(pos.x, pos.y);
rotate(angle);
strokeWeight(4);
stroke('green');
rectMode(CENTER);
fill(255);
rect(0, 0, this.width, this.height);
pop();
}
}
0 Comments: