diff game/js/render.js @ 24:3f2811aebb3d 0.9.0

splash screen buttons, help button, info screen
author ark
date 2026-10-20 15:58 +0200
parents 2f555a54c332
children 75deda08db90
line wrap: on
line diff
--- a/game/js/render.js	Tue Oct 20 12:04:42 2026 +0200
+++ b/game/js/render.js	Tue Oct 20 15:58:17 2026 +0200
@@ -120,6 +120,18 @@
         ctx.globalAlpha = 1;
     }
 
+    // freeze splash: drawn across the splash diameter. it grows from 60 % to
+    // full size over the first half of its time and fades out over the
+    // second half
+    function drawFreeze(ctx, f) {
+        var u = f.t / cfg.animation.freeze_splash;
+        var s = cfg.sprites.freeze;
+        var k = MM.util.lerp(0.6, 1, MM.util.easeOut(Math.min(1, u * 2)));
+        ctx.globalAlpha = 0.85 * (u < 0.5 ? 1 : 2 - 2 * u);
+        A.draw(ctx, "freeze", f.x, f.y, 2 * f.r / Math.max(s[0], s[1]), 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) {
@@ -149,6 +161,8 @@
             drawTower(ctx, pv, MM.util.lerp(0.45, 0.8, k), MM.util.lerp(1, 1.08, k));
         }
 
+        // the splashes lie on the ground, under the monsters
+        game.freezes.forEach(function (f) { drawFreeze(ctx, f); });
         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); });
@@ -156,6 +170,9 @@
             game.monsters.forEach(function (m) {
                 circle(ctx, m.x, m.y, m.hitRadius, null, "rgba(255, 0, 0, 0.8)", 1 / s);
             });
+            game.freezes.forEach(function (f) {
+                circle(ctx, f.x, f.y, f.r, null, "rgba(0, 90, 255, 0.8)", 1 / s);
+            });
         }
 
         game.projectiles.forEach(function (p) {