[SOLVED] Collision detection when using translate?

Hey guys, so I've been stuck for a while now..

I am using translate to focus the view on the player. The problem is, I'm not sure how I would then calculate the distance between the player and the objects in the world if the point of origin is always the player's x and y.

Without translating I would just use "dist()" to see if there's any overlap, but I'm not sure how to apply this when using translate().

I tried in vain to draw the objects and then calculate their position in separate variables relative to the player but it was a complete headache; I'm convinced there is an easier way.

I understand there are libraries for games and collisions but that wouldn't be any fun! :)

I've stripped my code to the relative parts and put it here: http://codepen.io/swhizzle/full/OpKyJQ/

Any advice will be really appreciated!

Steve

Sign In or Register to comment.