Skip to content

Commit

Permalink
Remove hard coded values
Browse files Browse the repository at this point in the history
  • Loading branch information
eonarheim committed Jul 28, 2023
1 parent 080e74a commit a93eb4e
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/tiled-map-resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,15 +165,20 @@ export class TiledMapResource implements Loadable<TiledMap> {
}

private _isoTileToScreenCoords(x: number, y: number) {
// Transformation sourced from:
// https://discourse.mapeditor.org/t/how-to-get-cartesian-coords-of-objects-from-tileds-isometric-map/4623/3
// TODO yank the real values from the map
const tileWidth = 111;
const tileHeight = 64;
const originX = 0;//20 * tileWidth / 2;
const tileY = y / tileHeight;
const tileX = x / tileHeight;
return vec((tileX - tileY) * tileWidth / 2 + originX,
(tileX + tileY) * tileHeight / 2);
if (this.isIsometric()) {
const map = this.isoLayers[0];
const tileWidth = map.tileWidth;
const tileHeight = map.tileHeight;
const originX = 0;
const tileY = y / tileHeight;
const tileX = x / tileHeight;
return vec(
(tileX - tileY) * tileWidth / 2 + originX,
(tileX + tileY) * tileHeight / 2);
}
return vec(x, y);
}

private _addTiledText(scene: Scene) {
Expand Down

0 comments on commit a93eb4e

Please sign in to comment.