wobblyhead hg > minor_monsters
diff game/js/input.js @ 6:910b26feca76
full game flow
| author | ark |
|---|---|
| date | 2026-10-19 01:05 +0200 |
| parents | 2d46729a022e |
| children | 2c4fed8baed9 |
line wrap: on
line diff
--- a/game/js/input.js Sun Oct 18 22:50:24 2026 +0200 +++ b/game/js/input.js Mon Oct 19 01:05:29 2026 +0200 @@ -9,7 +9,8 @@ var PREVIEW_HIT = 28; var REFUSED_TIME = 500; - // app: {canvas, game(), layout(), restart(), view} + // app: {canvas, view, game(), layout(), and the screen actions play(), + // next(), retry(), restart()} function attach(app) { var c = app.canvas; c.addEventListener("pointerdown", function (e) { @@ -34,15 +35,22 @@ var game = app.game(), L = app.layout(); var b = MM.ui.hit(game, L, x, y); if (b) { + // the play button starts the sound + if (b.id === "play") MM.audio.start(); MM.audio.play("button_tap"); - if (b.id === "restart") app.restart(); - else if (b.id === "pause") game.paused = !game.paused; + if (b.id === "play") app.play(); + else if (b.id === "next") app.next(); + else if (b.id === "retry") app.retry(); + else if (b.id === "restart") app.restart(); + else if (b.id === "pause") game.togglePause(); else if (b.id === "speed") game.speedIndex = (game.speedIndex + 1) % game.speeds.length; else if (b.id === "early") game.startEarly(); else if (b.id === "shop" && game.canAfford(MM.config.tower[b.tower].cost)) game.chooseShop(b.tower); + else if (b.id === "upgrade") game.upgrade(); + else if (b.id === "sell") game.sell(); return; } - if (game.result) return; + if (game.result || game.splash) return; var mx = (x - L.ox) / L.scale, my = (y - L.oy) / L.scale; if (mx < 0 || my < 0 || mx > game.map.width || my > game.map.height) return; var hitR = Math.max(MM.config.placement.footprint_radius, PREVIEW_HIT / L.scale);
