From 4d335c98dff79103ffc80e3bcb66dfaab291589a Mon Sep 17 00:00:00 2001 From: Sense101 <67970865+Sense101@users.noreply.github.com> Date: Fri, 2 Jul 2021 11:37:17 +0100 Subject: [PATCH] added letters and numbers on the side of the zone --- src/js/game/systems/zone.js | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/js/game/systems/zone.js b/src/js/game/systems/zone.js index 109f5166..932c24ea 100644 --- a/src/js/game/systems/zone.js +++ b/src/js/game/systems/zone.js @@ -61,7 +61,7 @@ export class ZoneSystem extends GameSystem { */ drawChunk(parameters, chunk) { if (this.drawn) { - // oof + // double oof return; } this.drawn = true; @@ -101,5 +101,31 @@ export class ZoneSystem extends GameSystem { ); context.globalAlpha = 1; + + // render zone indicators with letters and numbers + + context.font = "10px GameFont"; + context.fillStyle = "#626262"; + context.textAlign = "center"; + + const alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + + const halfTile = globalConfig.halfTileSize; + const pixelGap = 9; + const topLeft = zone.topLeft().add(new Vector(-pixelGap, -pixelGap)); + + for (let i = 0; i < zones[0].h; ++i) { + const letter = alphabet[i]; + + const pxOffset = halfTile + i * globalConfig.tileSize + pixelGap; + + context.fillText(letter, topLeft.x, topLeft.y + pxOffset + 5); + } + + for (let i = 0; i < zones[0].w; ++i) { + const pxOffset = halfTile + i * globalConfig.tileSize + pixelGap; + + context.fillText((i + 1).toString(), topLeft.x + pxOffset, topLeft.y + 3); + } } }