wobblyhead hg > minor_monsters
comparison game/js/game.js @ 23:2f555a54c332
layout fixes and balancing
| author | ark |
|---|---|
| date | 2026-10-20 12:04 +0200 |
| parents | fe680946164b |
| children | 3f2811aebb3d |
comparison
equal
deleted
inserted
replaced
| 22:ad1b478fc4dc | 23:2f555a54c332 |
|---|---|
| 68 // one simulation step of dt seconds | 68 // one simulation step of dt seconds |
| 69 Game.prototype.step = function (dt) { | 69 Game.prototype.step = function (dt) { |
| 70 if (this.result) return; | 70 if (this.result) return; |
| 71 var self = this; | 71 var self = this; |
| 72 this.time += dt; | 72 this.time += dt; |
| 73 this.waves.update(dt, this.monsters.length, function (kind) { | 73 this.waves.update(dt, function (kind) { |
| 74 var m = MM.monster.create(self, kind); | 74 var m = MM.monster.create(self, kind); |
| 75 self.monsters.push(m); | 75 self.monsters.push(m); |
| 76 MM.audio.play(m.boss ? "boss_enter" : "monster_enter"); | 76 MM.audio.play(m.boss ? "boss_enter" : "monster_enter"); |
| 77 }); | 77 }); |
| 78 this.monsters.forEach(function (m) { | 78 this.monsters.forEach(function (m) { |
| 125 this.puffs.push({ x: m.x, y: m.y, boss: m.boss, t: 0 }); | 125 this.puffs.push({ x: m.x, y: m.y, boss: m.boss, t: 0 }); |
| 126 // coins count at once; the flying coins only show it (balance.md) | 126 // coins count at once; the flying coins only show it (balance.md) |
| 127 this.coins += m.coins; | 127 this.coins += m.coins; |
| 128 var n = Math.min(m.coins, cfg.coins.max_sprites); | 128 var n = Math.min(m.coins, cfg.coins.max_sprites); |
| 129 for (var i = 0; i < n; i++) { | 129 for (var i = 0; i < n; i++) { |
| 130 this.flights.push({ | 130 this.flight(m.x + (this.random() - 0.5) * m.w, |
| 131 x: m.x + (this.random() - 0.5) * m.w, | 131 m.y - m.h / 2 + (this.random() - 0.5) * m.h / 2, i); |
| 132 y: m.y - m.h / 2 + (this.random() - 0.5) * m.h / 2, | 132 } |
| 133 sprite: "c" + Math.floor(this.random() * 4), | 133 }; |
| 134 // stagger the coins a little | 134 |
| 135 t: -i * 0.05 | 135 // the i-th coin of a group flying from (x, y) to the counter |
| 136 }); | 136 Game.prototype.flight = function (x, y, i) { |
| 137 } | 137 this.flights.push({ |
| 138 }; | 138 x: x, |
| 139 | 139 y: y, |
| 140 sprite: "c" + Math.floor(this.random() * 4), | |
| 141 // stagger the coins a little | |
| 142 t: -i * 0.05 | |
| 143 }); | |
| 144 }; | |
| 145 | |
| 146 // the bonus coins count at once and fly from the exits, taking turns | |
| 147 // if there are several | |
| 140 Game.prototype.startEarly = function () { | 148 Game.prototype.startEarly = function () { |
| 141 var bonus = this.waves.startEarly(); | 149 var bonus = this.waves.startEarly(); |
| 150 if (bonus <= 0) return; | |
| 142 this.coins += bonus; | 151 this.coins += bonus; |
| 143 if (bonus > 0) MM.audio.play("early_bonus"); | 152 MM.audio.play("early_bonus"); |
| 153 var exits = this.map.data.exits; | |
| 154 var n = exits.length ? Math.min(bonus, cfg.coins.max_sprites) : 0; | |
| 155 for (var i = 0; i < n; i++) { | |
| 156 var e = exits[i % exits.length]; | |
| 157 this.flight(e[0] + (this.random() - 0.5) * e[2], e[1] + (this.random() - 0.5) * e[2], i); | |
| 158 } | |
| 144 }; | 159 }; |
| 145 | 160 |
| 146 Game.prototype.towerAt = function (x, y) { | 161 Game.prototype.towerAt = function (x, y) { |
| 147 var r = cfg.placement.footprint_radius; | 162 var r = cfg.placement.footprint_radius; |
| 148 for (var i = 0; i < this.towers.length; i++) { | 163 for (var i = 0; i < this.towers.length; i++) { |
