Skip to content

Commit

Permalink
Address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
luanpotter committed Apr 29, 2024
1 parent 36e88b1 commit a23e627
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class IsometricTileMapComponent extends PositionComponent {

/// Displacement applied so that the origin of the component
/// matches the origin of the AABB.
final Vector2 _ds = Vector2.zero();
final Vector2 _offset = Vector2.zero();

IsometricTileMapComponent(
this.tileset,
Expand Down Expand Up @@ -136,7 +136,8 @@ class IsometricTileMapComponent extends PositionComponent {
final cartesianPosition = _cartesianPositionCache
..setValues(i.toDouble(), j.toDouble())
..multiply(halfTile);
return _ds + cartToIso(cartesianPosition)
return cartToIso(cartesianPosition)
..add(_offset)
..sub(halfTile);
}

Expand Down Expand Up @@ -181,7 +182,7 @@ class IsometricTileMapComponent extends PositionComponent {
final multiplier = 1 - halfTile.y / (2 * effectiveTileHeight * scale.x);
final iso = _getBlockIsoCache
..setFrom(p)
..sub(_ds)
..sub(_offset)
..sub(position)
..translate(halfTile.x, halfTile.y * multiplier);
final cart = isoToCart(iso);
Expand Down Expand Up @@ -235,7 +236,7 @@ class IsometricTileMapComponent extends PositionComponent {
size.x = effectiveTileSize.x * width;
size.y = effectiveTileSize.y * height / 2 + effectiveTileHeight;

_ds.x = size.x / 2;
_ds.y = effectiveTileHeight;
_offset.x = size.x / 2;
_offset.y = effectiveTileHeight;
}
}

0 comments on commit a23e627

Please sign in to comment.