wobblyhead hg > minor_monsters
diff game/js/ui.js @ 8:2c4fed8baed9
art update, persistent sound setting, tower selling as double action
| author | ark |
|---|---|
| date | 2026-10-19 13:37 +0200 |
| parents | 910b26feca76 |
| children | a77857594150 |
line wrap: on
line diff
--- a/game/js/ui.js Mon Oct 19 11:50:24 2026 +0200 +++ b/game/js/ui.js Mon Oct 19 13:37:52 2026 +0200 @@ -1,5 +1,6 @@ -// screen layout, top bar, tower shop, tower menu, splash and end screens. icons are placeholder -// shapes until the drawings arrive (art.md); numbers use a system font. +// screen layout, top bar, tower shop, tower menu, splash and end screens, +// drawn from the supplied icons and drawings (art.md). numbers use the +// hand-drawn digits. window.MM = window.MM || {}; @@ -11,12 +12,46 @@ var TOP = 60; // top bar height, css pixels var SHOP = 96; // shop width (landscape) or height (portrait) var BUTTON = 52; // top bar buttons, at least 48 for touch - var SHOP_BUTTON = 80; - var MENU_BUTTON = 64; // upgrade and sell, next to the selected tower + var SHOP_W = 84; // shop items + var SHOP_H = 72; + var POPUP_W = 168; // tower menu bubble; its height follows the drawing + var DIGIT = 28; // digit height in the top bar + var PRICE = 18; // digit height of prices + var DIGIT_GAP = 0.08; // space between digits, a share of their height + 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"]; + // each screen drawing, its separate button image and the button's action + var SCREENS = { + splash: { image: "splash_play", id: "play" }, + map_won: { image: "map_won_button", id: "next" }, + game_lost: { image: "game_lost_button", id: "retry" }, + game_won: { image: "game_won_button", id: "restart" } + }; + + // digit variants from the sprite table: character -> sprite names + var DIGITS = {}; + Object.keys(cfg.sprites).forEach(function (n) { + var m = /^digit_(\d|slash)_\d+$/.exec(n); + if (!m) return; + var ch = m[1] === "slash" ? "/" : m[1]; + (DIGITS[ch] = DIGITS[ch] || []).push(n); + }); + + // all screens share one scale, set by the largest drawing, so they keep + // the sizes of the drawings relative to each other + function screenScale(w, h) { + var mw = 0, mh = 0; + Object.keys(SCREENS).forEach(function (n) { + mw = Math.max(mw, cfg.sprites[n][0]); + mh = Math.max(mh, cfg.sprites[n][1]); + }); + return Math.min(1, 0.92 * w / mw, 0.9 * h / mh); + } // positions of everything on screen for a window of w x h css pixels function layout(w, h, map) { @@ -30,71 +65,98 @@ oy: area.y + (area.h - map.height * scale) / 2, shop: land ? { x: w - SHOP, y: TOP, w: SHOP, h: h - TOP } : { x: 0, y: h - SHOP, w: w, h: SHOP }, - coinIcon: { x: 26, y: TOP / 2, size: 28 } + coinIcon: { x: 24, y: TOP / 2, size: 32 }, + screen: screenScale(w, h) }; return L; } - // upgrade and sell buttons above the selected tower, or below it when - // there is no room above, kept inside the map area. no upgrade button - // at the top level. + // the screen shown over the map, or null during play + function screenName(game) { + if (game.splash) return "splash"; + if (game.result === "lost") return "game_lost"; + if (game.result) return game.lastMap() ? "game_won" : "map_won"; + return null; + } + + // the drawing of a screen centred in the window, and its button + function screenRects(name, L) { + var k = L.screen, s = cfg.sprites[name]; + var bs = cfg.sprites[SCREENS[name].image], at = cfg.art.screen[name]; + var p = { x: (L.w - s[0] * k) / 2, y: (L.h - s[1] * k) / 2, w: s[0] * k, h: s[1] * k }; + return { panel: p, button: { x: p.x + at[0] * k, y: p.y + at[1] * k, w: bs[0] * k, h: bs[1] * k } }; + } + + // the tower menu: a bubble above the selected tower, or below it when + // there is no room above, kept inside the map area. upgrade and sell each + // take half of the bubble; at the top level there is no upgrade and sell + // takes all of it. cx is where the button's drawing is centred. function towerMenu(game, L) { - var t = game.selected, a = L.area, gap = 8, out = []; + var t = game.selected, a = L.area, gap = 8; + var s = cfg.sprites.tower_popup, w = POPUP_W, h = POPUP_W * s[1] / s[0]; var x = L.ox + t.x * L.scale, y = L.oy + t.y * L.scale; var half = A.size(MM.tower.sprite(t), cfg.scale.sprite)[1] / 2 * L.scale + gap; - var w = 2 * MENU_BUTTON + gap; - var top = y - half - MENU_BUTTON; + var top = y - half - h; if (top < a.y + gap) top = y + half; var left = MM.util.clamp(x - w / 2, a.x + gap, a.x + a.w - w - gap); - if (MM.tower.upgradeCost(t)) { - out.push({ id: "upgrade", x: left, y: top, w: MENU_BUTTON, h: MENU_BUTTON }); + var bubble = { x: left, y: top, w: w, h: h }; + if (!MM.tower.upgradeCost(t)) { + return [{ id: "sell", x: left, y: top, w: w, h: h, cx: left + w / 2, bubble: bubble }]; } - out.push({ id: "sell", x: left + MENU_BUTTON + gap, y: top, w: MENU_BUTTON, h: MENU_BUTTON }); - return out; + return [ + { id: "upgrade", x: left, y: top, w: w / 2, h: h, cx: left + w * 0.34, bubble: bubble }, + { id: "sell", x: left + w / 2, y: top, w: w / 2, h: h, cx: left + w * 0.66, bubble: bubble } + ]; } // the buttons for the current state, each {id, x, y, w, h} function buttons(game, L) { var out = []; - var y = (TOP - BUTTON) / 2; - if (game.splash) { - out.push({ id: "play", x: L.w / 2 - 56, y: L.h / 2 + 10, w: 112, h: 112 }); - return out; - } - // map lost: back to the first map. map won: on to the next map, or - // after the last map back to the splash screen - if (game.result) { - var id = game.result === "lost" ? "retry" : game.lastMap() ? "restart" : "next"; - out.push({ id: id, x: L.w / 2 - 48, y: L.h / 2 + 50, w: 96, h: 96 }); + var name = screenName(game); + if (name) { + var b = screenRects(name, L).button; + b.id = SCREENS[name].id; + b.screen = name; + out.push(b); return out; } - out.push({ id: "pause", x: L.w - BUTTON - 8, y: y, w: BUTTON, h: BUTTON }); - out.push({ id: "speed", x: L.w - 2 * BUTTON - 16, y: y, w: BUTTON, h: BUTTON }); + // top bar, right to left + var y = (TOP - BUTTON) / 2, x = L.w - 8; + ["pause", "speed", "sound"].forEach(function (id) { + x -= BUTTON; + out.push({ id: id, x: x, y: y, w: BUTTON, h: BUTTON }); + x -= 8; + }); if (game.waves.phase === "break") { - out.push({ id: "early", x: L.w - 2 * BUTTON - 150, y: y, w: 126, h: BUTTON }); + var s = cfg.sprites.next_wave, w = BUTTON * s[0] / s[1]; + out.push({ id: "early", x: x - w, y: y, w: w, h: BUTTON }); } TOWERS.forEach(function (t, i) { - var pos = 10 + i * (SHOP_BUTTON + 10); - var b = L.land ? { x: L.shop.x + (SHOP - SHOP_BUTTON) / 2, y: L.shop.y + pos } - : { x: L.shop.x + pos, y: L.shop.y + (SHOP - SHOP_BUTTON) / 2 }; + var b = L.land ? { x: L.shop.x + (SHOP - SHOP_W) / 2, y: L.shop.y + 10 + i * (SHOP_H + 10) } + : { x: L.shop.x + 10 + i * (SHOP_W + 10), y: L.shop.y + (SHOP - SHOP_H) / 2 }; b.id = "shop"; b.tower = t; - b.w = b.h = SHOP_BUTTON; + b.w = SHOP_W; + b.h = SHOP_H; out.push(b); }); if (game.selected) out = out.concat(towerMenu(game, L)); return out; } + function inside(b, x, y) { + return x >= b.x && x < b.x + b.w && y >= b.y && y < b.y + b.h; + } + function hit(game, L, x, y) { var list = buttons(game, L); for (var i = 0; i < list.length; i++) { - var b = list[i]; - if (x >= b.x && x < b.x + b.w && y >= b.y && y < b.y + b.h) return b; + if (inside(list[i], x, y)) return list[i]; } 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"; @@ -106,102 +168,52 @@ ctx.fillText(s, x, y); } - // a sprite fitted into a box of size s, centred on x, y - function icon(ctx, name, x, y, s) { - var img = A.img(name); - var k = s / Math.max(img.naturalWidth, img.naturalHeight); - var w = img.naturalWidth * k, h = img.naturalHeight * k; - ctx.drawImage(img, x - w / 2, y - h / 2, w, h); - } - - function heart(ctx, x, y, s, fill) { - ctx.beginPath(); - ctx.moveTo(x, y + s * 0.4); - ctx.bezierCurveTo(x - s * 0.6, y, x - s * 0.5, y - s * 0.5, x, y - s * 0.2); - ctx.bezierCurveTo(x + s * 0.5, y - s * 0.5, x + s * 0.6, y, x, y + s * 0.4); - ctx.fillStyle = fill; - ctx.fill(); - ctx.lineWidth = 2; - ctx.strokeStyle = INK; - ctx.stroke(); + // 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]); + ctx.drawImage(A.img(name), x - s[0] * k / 2, y - s[1] * k / 2, s[0] * k, s[1] * k); } - function triangle(ctx, x, y, s) { - ctx.beginPath(); - ctx.moveTo(x - s * 0.35, y - s * 0.45); - ctx.lineTo(x + s * 0.45, y); - ctx.lineTo(x - s * 0.35, y + s * 0.45); - ctx.closePath(); - ctx.fill(); - } - - function star(ctx, x, y, r) { - ctx.beginPath(); - for (var i = 0; i < 10; i++) { - var a = -Math.PI / 2 + i * Math.PI / 5, rr = i % 2 ? r * 0.45 : r; - ctx.lineTo(x + Math.cos(a) * rr, y + Math.sin(a) * rr); + // the digit sprites for string s. the variant of each digit depends on + // the digit and its place counted from the right, so a number keeps its + // look while other places change. + function glyphs(s) { + var out = []; + for (var i = 0; i < s.length; i++) { + var list = DIGITS[s[i]]; + if (!list) continue; + var place = s.length - 1 - i; + out.push(list[(place * 5 + s.charCodeAt(i)) % list.length]); } - ctx.closePath(); - ctx.fillStyle = "#f2c230"; - ctx.fill(); - ctx.lineWidth = 3; - ctx.strokeStyle = INK; - ctx.stroke(); + return out; } - function restartIcon(ctx, x, y, r) { - ctx.lineWidth = 7; - ctx.strokeStyle = INK; - ctx.beginPath(); - ctx.arc(x, y, r, -Math.PI * 0.35, Math.PI * 1.45); - ctx.stroke(); - var a = -Math.PI * 0.35, tx = x + Math.cos(a) * r, ty = y + Math.sin(a) * r; - ctx.fillStyle = INK; - ctx.beginPath(); - ctx.moveTo(tx + 12, ty - 4); - ctx.lineTo(tx - 8, ty - 12); - ctx.lineTo(tx - 2, ty + 10); - ctx.closePath(); - ctx.fill(); - } - - function arrowRight(ctx, x, y, s) { - ctx.save(); - ctx.translate(x, y); - ctx.rotate(Math.PI / 2); - arrowUp(ctx, 0, 0, s); - ctx.restore(); + function numberWidth(s, h) { + var g = glyphs(s), w = 0; + g.forEach(function (n) { w += cfg.sprites[n][0] * h / cfg.sprites[n][1]; }); + return w + Math.max(0, g.length - 1) * h * DIGIT_GAP; } - function arrowUp(ctx, x, y, s) { - ctx.beginPath(); - ctx.moveTo(x, y - s * 0.5); - ctx.lineTo(x + s * 0.45, y); - ctx.lineTo(x + s * 0.17, y); - ctx.lineTo(x + s * 0.17, y + s * 0.5); - ctx.lineTo(x - s * 0.17, y + s * 0.5); - ctx.lineTo(x - s * 0.17, y); - ctx.lineTo(x - s * 0.45, y); - ctx.closePath(); - ctx.fill(); + // number s in digits of height h, vertically centred on y. align is + // "left", "center" or "right" of x. + function number(ctx, s, x, y, h, align) { + s = String(s); + var w = numberWidth(s, h); + if (align === "center") x -= w / 2; + else if (align === "right") x -= w; + glyphs(s).forEach(function (n) { + var gw = cfg.sprites[n][0] * h / cfg.sprites[n][1]; + ctx.drawImage(A.img(n), x, y - h / 2, gw, h); + x += gw + h * DIGIT_GAP; + }); } - function cross(ctx, x, y, s) { - ctx.lineWidth = 6; - ctx.lineCap = "round"; - ctx.beginPath(); - ctx.moveTo(x - s / 2, y - s / 2); - ctx.lineTo(x + s / 2, y + s / 2); - ctx.moveTo(x + s / 2, y - s / 2); - ctx.lineTo(x - s / 2, y + s / 2); - ctx.stroke(); - ctx.lineCap = "butt"; - } - - // a coin and an amount along the bottom of button b - function price(ctx, b, s) { - icon(ctx, "c0", b.x + 16, b.y + b.h - 13, 16); - text(ctx, s, b.x + 27, b.y + b.h - 12, "left", 18); + // a price, the coin icon followed by the amount, centred on x, y + function price(ctx, amount, x, y) { + var s = String(amount), coin = PRICE * 0.8, gap = 3; + var left = x - (coin + gap + numberWidth(s, PRICE)) / 2; + fit(ctx, "coin_icon", left + coin / 2, y, coin, coin); + number(ctx, s, left + coin + gap, y, PRICE, "left"); } function box(ctx, b, fill, line) { @@ -215,69 +227,76 @@ ctx.stroke(); } - function drawButton(ctx, game, b) { + // 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. + function screenButton(ctx, b, view) { var cx = b.x + b.w / 2, cy = b.y + b.h / 2; - if (b.id === "pause") { - box(ctx, b, game.paused ? "#ffe9a8" : PAPER); - ctx.fillStyle = INK; - if (game.paused) { - triangle(ctx, cx, cy, 26); - } else { - ctx.fillRect(cx - 10, cy - 12, 7, 24); - ctx.fillRect(cx + 3, cy - 12, 7, 24); - } + var hover = view.hover && inside(b, view.hover.x, view.hover.y); + var k = hover ? 1.08 : 1 + 0.04 * (0.5 - 0.5 * Math.cos(2 * Math.PI * view.now / 1000 / PULSE)); + var w = b.w * k, h = b.h * k; + ctx.save(); + if (hover) { + ctx.shadowColor = "rgba(0, 0, 0, 0.35)"; + ctx.shadowBlur = 12; + ctx.shadowOffsetY = 3; + } + ctx.drawImage(A.img(SCREENS[b.screen].image), cx - w / 2, cy - h / 2, w, h); + ctx.restore(); + } + + function drawButton(ctx, game, b, view) { + var cx = b.x + b.w / 2, cy = b.y + b.h / 2; + if (b.screen) { + screenButton(ctx, b, view); + } else if (b.id === "pause") { + // 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") { - // one triangle per speed step; numbers for the debug speeds - var sp = game.speed(); - box(ctx, b, sp > 1 ? "#ffe9a8" : PAPER); - ctx.fillStyle = INK; - if (sp <= 3) { - for (var i = 0; i < sp; i++) triangle(ctx, cx + (i - (sp - 1) / 2) * 12, cy, 20); + // 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 { - text(ctx, sp + "", cx, cy, "center"); + box(ctx, b, PAPER); + number(ctx, sp, cx, cy, DIGIT, "center"); } + } 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") { - box(ctx, b, PAPER); - ctx.fillStyle = INK; - triangle(ctx, b.x + 20, cy, 22); - ctx.fillRect(b.x + 29, cy - 10, 4, 20); - text(ctx, Math.ceil(game.waves.left) + "", b.x + 58, cy, "center"); - var bonus = game.waves.bonus(); - if (bonus > 0) text(ctx, "+" + bonus, b.x + b.w - 6, cy, "right", 18); + // the countdown fills the empty right part of the drawing + ctx.drawImage(A.img("next_wave"), b.x, b.y, b.w, b.h); + number(ctx, Math.ceil(game.waves.left), b.x + b.w * 0.66, cy, DIGIT, "center"); } else if (b.id === "shop") { var def = cfg.tower[b.tower]; - var ok = game.canAfford(def.cost); - box(ctx, b, game.shop === b.tower ? "#ffe9a8" : PAPER, - game.shop === b.tower ? "#c08000" : INK); - ctx.globalAlpha = ok ? 1 : 0.35; - icon(ctx, b.tower, cx, b.y + 30, 46); - icon(ctx, "c0", b.x + 22, b.y + b.h - 14, 16); - text(ctx, def.cost + "", b.x + 34, b.y + b.h - 13, "left", 18); + // the chosen item's bubble switches between its two drawings + var bubble = game.shop !== b.tower ? "shop_bubble" + : Math.floor(view.now / BUBBLE_FLIP) % 2 ? "shop_bubble_dark2" : "shop_bubble_dark"; + ctx.drawImage(A.img(bubble), b.x, b.y, b.w, b.h); + ctx.globalAlpha = game.canAfford(def.cost) ? 1 : 0.35; + fit(ctx, b.tower, cx, b.y + 28, 44, 38); + price(ctx, def.cost, cx, b.y + b.h - 15); ctx.globalAlpha = 1; } else if (b.id === "upgrade") { var cost = MM.tower.upgradeCost(game.selected); - box(ctx, b, PAPER); ctx.globalAlpha = game.canAfford(cost) ? 1 : 0.35; - ctx.fillStyle = INK; - arrowUp(ctx, cx, b.y + 22, 28); - price(ctx, b, cost + ""); + fit(ctx, "upgrade_button", b.cx, b.bubble.y + b.bubble.h * 0.4, 46, 44); + price(ctx, cost, b.cx, b.bubble.y + b.bubble.h * 0.7); ctx.globalAlpha = 1; } else if (b.id === "sell") { - box(ctx, b, PAPER); - ctx.strokeStyle = "#c03030"; - cross(ctx, cx, b.y + 22, 20); - price(ctx, b, "+" + MM.tower.refund(game.selected, game.pauseNumber())); - } else if (b.id === "play") { - box(ctx, b, PAPER); - ctx.fillStyle = INK; - triangle(ctx, cx + 4, cy, 60); - } else if (b.id === "next") { - box(ctx, b, PAPER); - ctx.fillStyle = INK; - arrowRight(ctx, cx, cy, 52); - } else if (b.id === "retry" || b.id === "restart") { - box(ctx, b, PAPER); - restartIcon(ctx, cx, cy, 26); + // armed by a first tap: a fast pulse with a red glow until the + // second tap sells + var k = 1; + ctx.save(); + if (game.sellArmed) { + k = 1 + 0.15 * (0.5 - 0.5 * Math.cos(2 * Math.PI * view.now / 1000 / WARN_PULSE)); + ctx.shadowColor = "rgba(220, 30, 20, 0.9)"; + ctx.shadowBlur = 14; + } + fit(ctx, "sell_button", b.cx, b.bubble.y + b.bubble.h * 0.4, 46 * k, 44 * k); + ctx.restore(); + price(ctx, MM.tower.refund(game.selected, game.pauseNumber()), b.cx, + b.bubble.y + b.bubble.h * 0.7); } } @@ -292,49 +311,34 @@ ctx.fillRect(L.shop.x, L.shop.y, L.shop.w, L.shop.h); ctx.fillStyle = "rgba(58, 53, 48, 0.25)"; ctx.fillRect(0, TOP - 2, L.w, 2); - icon(ctx, "c0", L.coinIcon.x, L.coinIcon.y, L.coinIcon.size); - text(ctx, game.coins + "", 46, TOP / 2); - heart(ctx, 126, TOP / 2 + 2, 30, "#e03a3a"); - text(ctx, game.hearts + "", 146, TOP / 2); - icon(ctx, "m0", 206, TOP / 2, 30); - text(ctx, game.waves.shown() + "/" + game.waves.list.length, 226, TOP / 2); + // each counter takes at least the width of its widest usual value, so + // the next one does not move while the numbers change + var ic = L.coinIcon, x = ic.x - ic.size / 2; + [["coin_icon", game.coins, "000"], ["heart", game.hearts, "00"], + ["monster_icon", game.waves.shown() + "/" + game.waves.list.length, "00/00"] + ].forEach(function (c) { + var s = String(c[1]); + fit(ctx, c[0], x + ic.size / 2, TOP / 2, ic.size, ic.size); + number(ctx, s, x + ic.size + 6, TOP / 2, DIGIT, "left"); + x += ic.size + 6 + Math.max(numberWidth(s, DIGIT), numberWidth(c[2], DIGIT)) + 18; + }); - var screen = game.splash || game.result; - if (!screen) buttons(game, L).forEach(function (b) { drawButton(ctx, game, b); }); - + var screen = screenName(game); + var list = buttons(game, L); if (game.paused && !screen) { ctx.fillStyle = "rgba(255, 255, 255, 0.18)"; ctx.fillRect(L.ox, L.oy, game.map.width * L.scale, game.map.height * L.scale); } - if (game.splash) { - // title and byline, placeholders until the drawings arrive - ctx.fillStyle = "rgba(246, 241, 230, 0.55)"; - ctx.fillRect(0, 0, L.w, L.h); - text(ctx, "minor monsters", L.w / 2, L.h / 2 - 90, "center", 60); - text(ctx, "By M.A. and J.A. Juszczyk", L.w / 2, L.h / 2 - 38, "center", 24); - } else if (game.result) { - ctx.fillStyle = "rgba(40, 35, 30, 0.45)"; + if (screen) { + ctx.fillStyle = game.splash ? "rgba(246, 241, 230, 0.55)" : "rgba(40, 35, 30, 0.45)"; ctx.fillRect(0, 0, L.w, L.h); - if (game.result === "won" && game.lastMap()) { - // game won: three stars - star(ctx, L.w / 2 - 125, L.h / 2 - 15, 50); - star(ctx, L.w / 2 + 125, L.h / 2 - 15, 50); - star(ctx, L.w / 2, L.h / 2 - 45, 70); - } else if (game.result === "won") { - star(ctx, L.w / 2, L.h / 2 - 40, 70); - } else { - heart(ctx, L.w / 2, L.h / 2 - 30, 140, "#8a8a8a"); - ctx.strokeStyle = INK; - ctx.lineWidth = 5; - ctx.beginPath(); - ctx.moveTo(L.w / 2 - 6, L.h / 2 - 72); - ctx.lineTo(L.w / 2 + 10, L.h / 2 - 40); - ctx.lineTo(L.w / 2 - 10, L.h / 2 - 20); - ctx.lineTo(L.w / 2 + 4, L.h / 2 + 22); - ctx.stroke(); - } + var p = screenRects(screen, L).panel; + ctx.drawImage(A.img(screen), p.x, p.y, p.w, p.h); + } else if (game.selected) { + var bub = list[list.length - 1].bubble; + ctx.drawImage(A.img("tower_popup"), bub.x, bub.y, bub.w, bub.h); } - if (screen) buttons(game, L).forEach(function (b) { drawButton(ctx, game, b); }); + list.forEach(function (b) { drawButton(ctx, game, b, view); }); if (cfg.debug.show_stats && view.stats) { var st = view.stats;
