WWPOL / Earth-Invader

WWPOL entry for JS13K. Play it here >>>
http://wwpol.github.io/Earth-Invader
1 stars 1 forks source link

Player rotation rotates player around start position, not current point #4

Closed ROODAY closed 10 years ago

ROODAY commented 10 years ago

Phil please help

liboan commented 10 years ago

Translate the context to the center of the player using gctx.translate(x,y). Two things to watch out for:

  1. All the drawing one does on a canvas is relative to the context. If you move it, weird stuff will happen.
  2. .translate(x,y) increments the context coordinates by (x,y). So if you do .translate(10,10), the context will move to 10,10, and to move it back, you need to do .translate(-10,-10).

I've done some of that in the turret code, which will be pushed soon...

ROODAY commented 10 years ago

Tried that, still won't work. Can you take a look? I may have messed up somewhere and not noticed it

liboan commented 10 years ago

.....ok nvm. right now the arrow keys for the turret move it in the cardinal directions only, the rotation (which follows the mouse) is completely independent. We'll have to consider if we want to implement the mouse-following movement (b/c after all, it's a turret and should be able to shoot in any direction regardless of which way it's moving)

ROODAY commented 10 years ago

Yeah I agree, the turret should be able to shoot anywhere. The movement is just for getting away from enemies. So stick with independent mouse?

liboan commented 10 years ago

Yes, i think we should stick with that at least for now.

ROODAY commented 10 years ago

wait I think we got off topic. The main issue is still there, at least in gh-pages. The context isn't translating to the player.

liboan commented 10 years ago

sorry, my bad.

It seems like you're doing the same as what I'm doing in the Turret class- i'll look closer.

(for reference, turret class is at https://github.com/WWPOL/Earth-Invader/blob/turret/js/turret.js)