Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - orientation = `orthogonal`
- - TileToWorldX
- ```javascript
- var TileToWorldX = function(tileX, tileY) {
- return tileX * tile.width;
- }
- ```
- - TileToWorldY
- ```javascript
- var TileToWorldY = function(tileX, tileY) {
- return tileY * tile.height;
- }
- ```
- - WorldToTileX
- ```javascript
- var WorldToTileX = function(worldX, worldY) {
- return Math.floor( worldX / tile.width );
- }
- ```
- - WorldToTileY
- ```javascript
- var WorldToTileY = function(worldX, worldY) {
- return Math.floor( worldY / tile.height );
- }
- ```
- - orientation = `isometric`
- - TileToWorldX
- ```javascript
- var TileToWorldX = function(tileX, tileY) {
- return (tileX - tileY) * (tile.width * 0.5);
- }
- ```
- - TileToWorldY
- ```javascript
- var TileToWorldY = function(tileX, tileY) {
- return (tileX + tileY) * (tile.height * 0.5);
- }
- ```
- - WorldToTileX
- ```javascript
- var WorldToTileX = function(worldX, worldY) {
- return 0.5 * (
- Math.floor(worldY / (tile.height * 0.5)) +
- Math.floor(worldX / (tile.width * 0.5))
- );
- }
- ```
- - WorldToTileY
- ```javascript
- var WorldToTileY = function(worldX, worldY) {
- return 0.5 * (
- Math.floor(worldY / (tile.height * 0.5)) -
- Math.floor(worldX / (tile.width * 0.5))
- );
- }
- ```
Add Comment
Please, Sign In to add comment