make sure Hex stuff still works

This commit is contained in:
Gavin McDonald
2018-06-24 14:58:31 -04:00
parent bf37910877
commit 3830419b72
4 changed files with 39 additions and 168 deletions

View File

@@ -14,17 +14,34 @@ export {DrawCircle, DrawHexagon, DrawSquare};
import Cell from './cell.js';
export {Cell};
//import ExWhy from './exWhy.js';
//import ExWhyZee from './exWhyZee.js';
import CartographerXY from './cartographerXY.js';
import CartographerXYZ from './cartographerXYZ.js';
const HEX = 'hex';
const CIRCLE = 'circle';
const SQUARE = 'square';
const TILE_STYLES = {HEX, CIRCLE, SQUARE};
const TILES = {
[HEX]: new DrawHexagon(),
[CIRCLE]: new DrawCircle(),
[SQUARE]: new DrawSquare(),
};
const DEFAULTS = {
tile: HEX,
board: HEX,
tap: utils.noop,
draw: utils.noop,
pointyTop: false,
};
export default class Tessellate {
static get TILES () {return TILES}
static get TILE_STYLES () {return TILE_STYLES}
static get BOARD_STYLES () {return {HEX, SQUARE}}
constructor(settings) {
['tap', 'draw', 'drawMap', 'move', 'zoom'].map(method => {this[method] = this[method].bind(this)});
@@ -45,15 +62,14 @@ export default class Tessellate {
});
this.map = [];
this.cartographer = new CartographerXY({
const boardSettings = {
pointyTop: this.settings.pointyTop,
originX: this.sketch.getContext().canvas.width / 2,
originY: this.sketch.getContext().canvas.height / 2
});
};
this.circle = new DrawCircle();
this.hexagon = new DrawHexagon();
this.square = new DrawSquare();
this.cartographer = this.settings.board === HEX ? new CartographerXYZ(boardSettings) : new CartographerXY(boardSettings);
}
tap(event) {
@@ -106,7 +122,7 @@ export default class Tessellate {
});
}
this.square.filled(context, scale, tilePoint.getX(), tilePoint.getY(), this.map[tile.getX()][tile.getY()]);
TILES[this.settings.tile].filled(context, scale, tilePoint.getX(), tilePoint.getY(), this.map[tile.getX()][tile.getY()]);
// let cell = map.getXY(hex.getX(), hex.getY());
//