wobblyhead hg > minor_monsters
diff game/js/render.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/render.js Mon Oct 19 11:50:24 2026 +0200 +++ b/game/js/render.js Mon Oct 19 13:37:52 2026 +0200 @@ -108,6 +108,17 @@ } } + // death puff: grows from 60 % to full size, and fades out over the second + // half of its time + function drawPuff(ctx, p) { + var u = p.t / cfg.animation.death_puff; + var k = MM.util.lerp(0.6, 1, MM.util.easeOut(Math.min(1, u * 2))); + var name = p.boss ? "boss_death" : "monster_death"; + ctx.globalAlpha = u < 0.5 ? 1 : 2 - 2 * u; + A.draw(ctx, name, p.x, p.y, cfg.scale.sprite, null, k, k); + ctx.globalAlpha = 1; + } + // draw the map area. L is the layout from ui.js, view holds the canvas // pixel ratio, wall clock and tap feedback. function draw(ctx, game, L, view) { @@ -136,6 +147,7 @@ game.monsters.slice().sort(function (a, b) { return a.y - b.y; }) .forEach(function (m) { drawMonster(ctx, m, game.time); }); + game.puffs.forEach(function (p) { drawPuff(ctx, p); }); if (dbg.show_hit_areas) { game.monsters.forEach(function (m) { circle(ctx, m.x, m.y, m.hitRadius, null, "rgba(255, 0, 0, 0.8)", 1 / s);
