wobblyhead hg > minor_monsters
diff game/js/ui.js @ 27:75deda08db90 0.9.1
game debug functions separated into own file; release build option, distribution script
| author | ark |
|---|---|
| date | 2026-10-20 17:19 +0200 |
| parents | 3f2811aebb3d |
| children | 85d23328a215 |
line wrap: on
line diff
--- a/game/js/ui.js Tue Oct 20 16:06:50 2026 +0200 +++ b/game/js/ui.js Tue Oct 20 17:19:40 2026 +0200 @@ -21,9 +21,6 @@ var BUBBLE_FLIP = 400; // ms between the two drawings of the chosen shop item var PULSE = 1.2; // seconds of one pulse of a screen button var WARN_PULSE = 0.5; // seconds of one pulse of an armed sell button - var INK = "#3a3530"; - var PAPER = "#f6f1e6"; - var FONT = "bold 22px system-ui, -apple-system, Segoe UI, sans-serif"; var TOWERS = ["t0", "t1", "t2", "t3"]; // widest usual values of the coin, heart and wave counters var USUAL = ["000", "00", "00/00"]; @@ -209,18 +206,6 @@ return null; } - // system font text, for the debug stats only - function text(ctx, s, x, y, align, size) { - ctx.font = size ? FONT.replace("22px", size + "px") : FONT; - ctx.textAlign = align || "left"; - ctx.textBaseline = "middle"; - ctx.lineWidth = 4; - ctx.strokeStyle = PAPER; - ctx.strokeText(s, x, y); - ctx.fillStyle = INK; - ctx.fillText(s, x, y); - } - // a sprite fitted into a box of w x h centred on x, y, keeping its shape function fit(ctx, name, x, y, w, h) { var s = cfg.sprites[name], k = Math.min(w / s[0], h / s[1]); @@ -269,17 +254,6 @@ number(ctx, s, left + coin + gap, y, PRICE, "left"); } - function box(ctx, b, fill, line) { - ctx.fillStyle = fill; - ctx.strokeStyle = line || INK; - ctx.lineWidth = 2; - ctx.beginPath(); - if (ctx.roundRect) ctx.roundRect(b.x, b.y, b.w, b.h, 10); - else ctx.rect(b.x, b.y, b.w, b.h); - ctx.fill(); - ctx.stroke(); - } - // a screen's button image over the same button in the drawing. it pulses // slowly as a cue to tap; under the mouse it is drawn larger, lifted by // a shadow. @@ -308,14 +282,7 @@ // shows what a tap does: pause while running, play while paused fit(ctx, game.paused ? "play_button" : "pause_button", cx, cy, b.w, b.h); } else if (b.id === "speed") { - // debug speeds have no drawing and show their number - var sp = game.speed(), name = "speed_x" + sp; - if (cfg.sprites[name]) { - fit(ctx, name, cx, cy, b.w, b.h); - } else { - box(ctx, b, PAPER); - number(ctx, sp, cx, cy, DIGIT, "center"); - } + fit(ctx, "speed_x" + game.speed(), cx, cy, b.w, b.h); } else if (b.id === "sound") { fit(ctx, MM.audio.enabled() ? "sound_on" : "sound_off", cx, cy, b.w, b.h); } else if (b.id === "early") { @@ -397,13 +364,6 @@ ctx.drawImage(A.img("tower_popup"), bub.x, bub.y, bub.w, bub.h); } list.forEach(function (b) { drawButton(ctx, game, b, view); }); - - if (cfg.debug.show_stats && view.stats) { - var st = view.stats; - text(ctx, st.ms.toFixed(1) + " ms " + game.monsters.length + " m " + - game.towers.length + " t " + game.projectiles.length + " p seed " + game.seed, - 8, L.h - 14, "left", 14); - } } return { layout: layout, hit: hit, draw: draw, BUBBLE_FLIP: BUBBLE_FLIP };
