From 926de8edc185b92f50ca825637e870dabeb0f8eb Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Wed, 30 Jul 2014 01:25:29 +0200 Subject: [PATCH] maybe fix showing cannon fire on death --- tanks.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) 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;