fixed block width calculation
This commit is contained in:
parent
b4877c3e97
commit
2bc6560ba4
1 changed files with 7 additions and 7 deletions
14
main.js
14
main.js
|
@ -71,7 +71,7 @@ function Block(lane, color, distFromHex) {
|
|||
this.distFromHex = 300;
|
||||
}
|
||||
this.draw = function() {
|
||||
this.width = this.distFromHex;
|
||||
this.width = 2 * this.distFromHex / Math.sqrt(3) + this.height;
|
||||
var p1 = rotatePoint(-this.width/2, this.height/2, this.angle);
|
||||
var p2 = rotatePoint(this.width/2, this.height/2, this.angle);
|
||||
var p3 = rotatePoint(this.width/2, -this.height/2, this.angle);
|
||||
|
@ -90,12 +90,12 @@ function Block(lane, color, distFromHex) {
|
|||
ctx.closePath();
|
||||
ctx.fill();
|
||||
|
||||
ctx.strokeStyle = '#322'
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(canvas.width/2, canvas.height/2);
|
||||
ctx.lineTo(canvas.width/2 + Math.sin((this.angle) * (Math.PI/180)) * (this.distFromHex + this.height), canvas.height/2 - Math.cos((this.angle) * (Math.PI/180)) * (this.distFromHex + this.height));
|
||||
ctx.closePath();
|
||||
ctx.stroke();
|
||||
// ctx.strokeStyle = '#322'
|
||||
// ctx.beginPath();
|
||||
// ctx.moveTo(canvas.width/2, canvas.height/2);
|
||||
// ctx.lineTo(canvas.width/2 + Math.sin((this.angle) * (Math.PI/180)) * (this.distFromHex + this.height), canvas.height/2 - Math.cos((this.angle) * (Math.PI/180)) * (this.distFromHex + this.height));
|
||||
// ctx.closePath();
|
||||
// ctx.stroke();
|
||||
};
|
||||
|
||||
}
|
Loading…
Reference in a new issue