Flags (#12)
This commit is contained in:
36
src/main.js
36
src/main.js
@@ -39,6 +39,7 @@ class Demo {
|
||||
|
||||
this.map = {};
|
||||
this.taps = [];
|
||||
this.flags = {};
|
||||
this.ripples = [];
|
||||
this.setOriginTile();
|
||||
|
||||
@@ -89,7 +90,8 @@ class Demo {
|
||||
|
||||
const key = `${ x },${ z != null ? z : y }`;
|
||||
|
||||
this.map[key].pips = Tessellate.utils.random(1,7);
|
||||
const pipMax = this.settings.tile === Tessellate.TILE_STYLES.HEX ? 7 : 9;
|
||||
this.map[key].pips = Tessellate.utils.random(1, pipMax);
|
||||
console.log(this.map[key].pips);
|
||||
}
|
||||
|
||||
@@ -114,18 +116,27 @@ class Demo {
|
||||
})
|
||||
});
|
||||
|
||||
this.taps.push(this.createTile({
|
||||
x: tap.tile.x,
|
||||
y: tap.tile.y,
|
||||
|
||||
drawStyle: Tessellate.utils.random(Tessellate.DRAW_STYLES),
|
||||
tileStyle: Tessellate.utils.random(Tessellate.TILE_STYLES),
|
||||
orientation: Tessellate.utils.random(Tessellate.TILE_ORIENTATIONS),
|
||||
}));
|
||||
if (tap.event.mobile) {
|
||||
this.toggleFlag(tap.tile)
|
||||
}
|
||||
}
|
||||
|
||||
press(tap) {
|
||||
console.log('PRESS END');
|
||||
if (!tap.event.mobile) {
|
||||
this.toggleFlag(tap.tile)
|
||||
}
|
||||
}
|
||||
|
||||
toggleFlag(tile) {
|
||||
const {x, y, z} = tile.getPoint();
|
||||
const key = `${ x },${ z != null ? z : y }`;
|
||||
|
||||
if (this.flags[key]) {
|
||||
delete this.flags[key];
|
||||
}
|
||||
else {
|
||||
this.flags[key] = tile;
|
||||
}
|
||||
}
|
||||
|
||||
createTile({x, y,
|
||||
@@ -193,6 +204,11 @@ class Demo {
|
||||
Tessellate.TILES[cell.tileStyle][cell.drawStyle](context, scale, pixelPoint.getX(), pixelPoint.getY(), cell);
|
||||
});
|
||||
|
||||
Tessellate.funky.forEach(this.flags, cell => {
|
||||
const pixelPoint = this.tessellate.tileToPixel(cell.x, cell.y);
|
||||
Tessellate.TILES[this.settings.tile].flag(context, scale, pixelPoint.getX(), pixelPoint.getY());
|
||||
});
|
||||
|
||||
if (!this.notFirstTime) {
|
||||
this.notFirstTime = true;
|
||||
console.log(tilePoints);
|
||||
|
||||
Reference in New Issue
Block a user