Last active
May 30, 2018 21:12
-
-
Save jamesplease/4831bf12f72d39d99eff3c2caf3b6841 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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