wobblyhead hg > minor_monsters
diff game/js/game.js @ 13:8df95050fc8b
no more build during pause; tower popup closes on any click outside it
| author | ark |
|---|---|
| date | 2026-10-19 21:59 +0200 |
| parents | a77857594150 |
| children | 7fda634d15ad |
line wrap: on
line diff
--- a/game/js/game.js Mon Oct 19 20:41:45 2026 +0200 +++ b/game/js/game.js Mon Oct 19 21:59:53 2026 +0200 @@ -25,7 +25,6 @@ this.waves = new MM.Waves(mapIndex, MM.util.clamp(firstWave - 1, 0, mc.waves.length - 1)); this.time = 0; this.paused = false; - this.pauses = 0; // number of pauses so far, for the sell refund this.speeds = cfg.controls.speeds.concat(dbg.extra_speeds); this.speedIndex = 0; this.result = null; // "won" or "lost" @@ -45,14 +44,16 @@ return this.map.index === MM.maps.length - 1; }; + // towers cannot be built, upgraded or sold while paused, so pausing + // drops the shop choice, its preview and the tower selection Game.prototype.togglePause = function () { this.paused = !this.paused; - if (this.paused) this.pauses++; - }; - - // number of the current pause, 0 while the game runs - Game.prototype.pauseNumber = function () { - return this.paused ? this.pauses : 0; + if (this.paused) { + this.shop = null; + this.preview = null; + this.selected = null; + this.sellArmed = false; + } }; Game.prototype.canAfford = function (cost) { @@ -202,7 +203,7 @@ this.pay(cost); var pv = this.preview; var t = MM.tower.create(this.shop, pv.x, pv.y, pv.sides); - t.paid.push({ cost: cost, pause: this.pauseNumber() }); + t.paid += cost; this.towers.push(t); MM.audio.play("tower_built"); this.shop = null; @@ -217,7 +218,7 @@ if (!cost || !this.canAfford(cost)) return; this.pay(cost); t.level++; - t.paid.push({ cost: cost, pause: this.pauseNumber() }); + t.paid += cost; MM.audio.play("tower_upgraded"); }; @@ -230,7 +231,7 @@ return; } this.sellArmed = false; - this.coins += MM.tower.refund(t, this.pauseNumber()); + this.coins += MM.tower.refund(t); this.towers.splice(this.towers.indexOf(t), 1); this.selected = null; MM.audio.play("tower_sold");
