braingdx icon indicating copy to clipboard operation
braingdx copied to clipboard

Support isometric positioning

Open bitbrain opened this issue 4 years ago • 0 comments

Currently, positioning is always orthogonal and does not consider other tiled maps such as isometric. As a result, positioning an object within Tiled has a different result within braingdx.

New Terminology

  • Map Position a map position is the amount of pixels (x,y) distanced from the origin, however in the orientation of the tiled map itself.
  • World Position world position is the amount of pixels (x,y) distanced from the origin (0,0)
  • Indexed Position an indexed position is the distance of tiles distanced from the origin tile

Design

The new design for position calculations still requires translations between indices and positions, as well as translating map positions to world positions.

interface PositionTranslator {
   float toWorldX(int indexX);
   float toWorldY(int indexY);
   float toWorldX(float mapX);
   float toWorldY(float mapY);
   int toIndexX(float worldX);
   int toIndexY(float worldY);
}

see reference implementation

bitbrain avatar Jul 27 '19 16:07 bitbrain