wobblyhead hg > minor_monsters
diff game/js/projectile.js @ 24:3f2811aebb3d 0.9.0
splash screen buttons, help button, info screen
| author | ark |
|---|---|
| date | 2026-10-20 15:58 +0200 |
| parents | fe680946164b |
| children |
line wrap: on
line diff
--- a/game/js/projectile.js Tue Oct 20 12:04:42 2026 +0200 +++ b/game/js/projectile.js Tue Oct 20 15:58:17 2026 +0200 @@ -1,5 +1,5 @@ -// projectiles: fly towards their target and damage it on arrival, p2 also -// slows it +// projectiles: fly towards their target and damage it on arrival. p2 does +// no damage; it bursts where it lands and slows every monster nearby window.MM = window.MM || {}; @@ -19,13 +19,14 @@ damage: damage, slow: def.slow ? def.slow[tower.level - 1] : 0, slowTime: def.slow_time, + splash: def.splash_radius || 0, angle: Math.atan2(target.y - tower.y, target.x - tower.x), done: false }; } // home in on the target. if it died first, fly on to its last position - // and disappear there without damage. + // and disappear there without damage; a splash still bursts there. function update(p, game, dt) { var t = p.target; if (t && t.alive) { @@ -39,9 +40,11 @@ var step = p.speed * dt; var reach = t ? Math.max(step, t.hitRadius) : step; if (d <= reach) { - if (t) { + if (p.splash) { + game.freeze(p.tx, p.ty, p.splash, p.slow, p.slowTime); + } else if (t) { if (p.slow) MM.monster.slow(t, p.slow, p.slowTime); - game.damage(t, p.damage); + if (p.damage) game.damage(t, p.damage); } p.done = true; return;
