Skip to content

Instantly share code, notes, and snippets.

@jamesplease
Last active May 30, 2018 21:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamesplease/4831bf12f72d39d99eff3c2caf3b6841 to your computer and use it in GitHub Desktop.
Save jamesplease/4831bf12f72d39d99eff3c2caf3b6841 to your computer and use it in GitHub Desktop.
positionMap(coordinates, tileHeight, tileWidth) {
// At (0, 0), where do we render? It is as these coordinates.
const initialX = tileWidth / 2;
const initialY = tileHeight / 2;
const xPositionFromX = coordinates.x * (tileWidth);
const xPositionFromY = coordinates.y * (-tileWidth);
const yPositionFromX = coordinates.x * (-tileHeight);
const yPositionFromY = coordinates.y * (-tileHeight);
return {
x: initialX + xPositionFromX + xPositionFromY,
y: initialY + yPositionFromX + yPositionFromY
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment