Added grid scale and offset to maps and refactored into grid object

This commit is contained in:
Mitchell McCaffrey
2020-10-02 15:19:10 +10:00
parent 54a60d6c76
commit 539f216cfe
9 changed files with 46 additions and 22 deletions

View File

@@ -86,7 +86,10 @@ function MapToken({
x: tokenGroup.x() + tokenGroup.width() / 2,
y: tokenGroup.y() + tokenGroup.height() / 2,
};
const gridSize = { x: mapWidth / map.gridX, y: mapHeight / map.gridY };
const gridSize = {
x: mapWidth / map.grid.size.x,
y: mapHeight / map.grid.size.y,
};
const gridSnap = Vector2.roundTo(position, gridSize);
const gridDistance = Vector2.length(Vector2.subtract(gridSnap, position));
const minGrid = Vector2.min(gridSize);