display tiles, pips, and mines along with FPS
This commit is contained in:
17
src/main.js
17
src/main.js
@@ -202,6 +202,8 @@ class Demo {
|
||||
}
|
||||
|
||||
drawTile({x, y, z}, context, scale) {
|
||||
this.counts[0] += 1;
|
||||
|
||||
const key = `${ x },${ z != null ? z : y }`;
|
||||
|
||||
this.map[key] = this.map[key] || this.createTile({
|
||||
@@ -218,11 +220,19 @@ class Demo {
|
||||
tile = this.gray ? this.fadeToGray(tile, fadeFactor) : tile;
|
||||
|
||||
Tessellate.TILES[tile.tileStyle][tile.drawStyle](context, scale, pixelPoint.getX(), pixelPoint.getY(), tile);
|
||||
Tessellate.Shapes.pips(context, scale, pixelPoint.getX(), pixelPoint.getY(), tile);
|
||||
|
||||
if (tile.pips) {
|
||||
this.counts[1] += tile.pips;
|
||||
Tessellate.Shapes.pips(context, scale, pixelPoint.getX(), pixelPoint.getY(), tile);
|
||||
}
|
||||
}
|
||||
|
||||
draw({context, height, width, scale, tilePoints, now, lastNow}) {
|
||||
this.fps.frame(now, lastNow);
|
||||
this.counts = [
|
||||
0, // tiles
|
||||
0, // pips
|
||||
0, // mines
|
||||
];
|
||||
|
||||
Tessellate.Shapes.background(context, height, width, {
|
||||
red: 64,
|
||||
@@ -249,9 +259,12 @@ class Demo {
|
||||
});
|
||||
|
||||
Tessellate.funky.forEach(this.mines, cell => {
|
||||
this.counts[2] += 1;
|
||||
const pixelPoint = this.tessellate.tileToPixel(cell.x, cell.y);
|
||||
Tessellate.Shapes.mine(context, scale, pixelPoint.getX(), pixelPoint.getY());
|
||||
});
|
||||
|
||||
this.fps.frame(now, lastNow, this.counts);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user