I stopped reading through the code when I got to this:
if (descendAttack || rightMouseActionHappening){ if (!rightMouseActionHappening){ rightMouseActionHappening = true; } //200 is pretty badass }
First, that comment means nothing to the code, get rid of it.
Second thing is that the inside operation will never get called when rightMouseActionHappening is true, I am not sure how this is supposed to work, if you try something like
if (true) { if (false){ console.log("true"); } } you won't get an answer from it, so what I mean is that you should write this a little more like this
if (descendAttack && !rightMouseActionHappening){ rightMouseActionHappening = true; } because the inner if isn't going to be called if rightMouseActionHappening is true, so don't test for that.
once we have gone this far, if rightMouseActionHappening is true, reassigning it to true isn't going to hurt it at all, so we might as well drop it off.
if (descendAttack){ rightMouseActionHappening = true; } Now, the next statement is another if checking descendAttack again, so we might just want to merge these together like this
if (descendAttack) { rightMouseActionHappening = true; ctx.save(); ctx.translate(bugX+60, fly.getDrawAtY()-40 + 90); ctx.rotate(Math.PI); ctx.drawImage(silverSword, 0, -10); ctx.restore(); } else { ctx.drawImage(silverSword, bugX+ 60, fly.getDrawAtY()-40); } all of your code could use another indentation inside of the functions, so that I know that it is inside of a function.
if (skeleton.getMoveDirection() === "left"){ facing_left = true; } else if (skeleton.getMoveDirection() === "right"){ facing_left = false; }
I would change this into a simple assignment like this
facing_left = skeleton.getMoveDirection() === "left" and this
if (facing_left){ spritesheet_offset_y = 102; } else { spritesheet_offset_y = 0; }
I would change into a ternary assignment statement like this
spritesheet_offset_y = facing_left ? 102 : 0;