pointy top squares

This commit is contained in:
Gavin McDonald
2018-06-24 21:58:28 -04:00
parent 3830419b72
commit bf30d0d303
4 changed files with 14 additions and 14 deletions

View File

@@ -55,10 +55,10 @@ export default class CartographerXY extends Cartographer {
const minWidth = (a) => this.minWidth() * a;
const maxWidth = (a) => this.maxWidth() * a;
const maxWidth = (a, b) => (this.maxWidth() * a) + ((b % 2) * (this.maxWidth() / 2));
let pixelX = this.pointyTop ? maxWidth(square.getX()) : minWidth(square.getX());
let pixelY = this.pointyTop ? maxWidth(square.getY()) : minWidth(square.getY());
let pixelX = this.pointyTop ? maxWidth(square.getX(), square.getY()) : minWidth(square.getX());
let pixelY = this.pointyTop ? (this.maxWidth() / 2) * square.getY() : minWidth(square.getY());
pixelX += this.originX;
pixelY += this.originY;
@@ -69,7 +69,7 @@ export default class CartographerXY extends Cartographer {
pixelToTile(point) {
let scale = this.scale;
const radiusLong = a => a / this.maxWidth();
const radiusLong = a => (a / (this.maxWidth() / 2));
const radiusShort = a => a / this.minWidth();
let pixelX = point.getX() - this.originX;
@@ -96,7 +96,7 @@ export default class CartographerXY extends Cartographer {
for (let row = 0; row <= height; row++) {
tiles[row] = [];
let y = upperLeftTile.getY() + row;
let xOffset = upperLeftTile.getX();
let xOffset = upperLeftTile.getX() - (row % 2);
for (let x = xOffset; x <= xOffset + width; x++) {
tiles[row].push(new Square(x, y));