diff --git a/tanks.js b/tanks.js index 3f11bc9..e44d880 100644 --- a/tanks.js +++ b/tanks.js @@ -62,11 +62,7 @@ function Tank(ctx, width, height, color, sensors) { if (!this.dead) { return; } - if (this.fire == 5) { - // one frame of cannon fire - this.draw_cannon(); - this.fire = 0; - } + var points = 7; var angle = Math.PI / points; @@ -74,6 +70,15 @@ function Tank(ctx, width, height, color, sensors) { ctx.translate(this.x, this.y); ctx.rotate(this.rotation); + if (this.fire == 5) { + ctx.save(); + ctx.rotate(this.turret); + // one frame of cannon fire + this.draw_cannon(); + this.fire = 0; + ctx.restore(); + } + ctx.lineWidth = 2; ctx.strokeStyle = craterStroke; ctx.fillStyle = craterFill;