I cipressi ondeggiano morbidi, tutti interi dalla base, invece che a fasce

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ApqNBvNbNCwXqR2RLo8QJh
This commit is contained in:
2026-10-24 23:47:04 +02:00
co-authored by Claude Opus 5.5
parent 186ed38dd3
commit 86f8df16b1
+10 -7
View File
@@ -331,17 +331,20 @@ export const EFFECTS = {
ctx.fillRect(x + 2, y - up, 2, 1); ctx.fillRect(x + 2, y - up, 2, 1);
} }
}, },
// Alberi al vento (i cipressi): un pezzo di sfondo ridisegnato inclinato appena, più in cima che alla base. // Alberi al vento (i cipressi): il pezzo di sfondo si piega tutto insieme dalla base, di frazioni di pixel e con
// due onde lente sovrapposte, così il movimento è morbido e non a scatti.
sway(ctx, e, time, game) { sway(ctx, e, time, game) {
const bg = backgrounds.get(game.scene.background); const bg = backgrounds.get(game.scene.background);
if (!bg) return; if (!bg) return;
const k = bg.width / WIDTH; const k = bg.width / WIDTH, amount = e.amount ?? 1.2;
for (const [i, [x, y, w, h]] of e.rects.entries()) { for (const [i, [x, y, w, h]] of e.rects.entries()) {
const a = Math.sin(time / (e.speed ?? 900) + i * 1.3) * (e.amount ?? 1.6); const a = amount * (0.65 * Math.sin(time / 1900 + i * 1.7) + 0.35 * Math.sin(time / 830 + i * 2.9));
for (let r = 0; r < h; r += 2) { ctx.save();
const dx = Math.round(a * (1 - r / h)); ctx.imageSmoothingEnabled = true;
if (dx) ctx.drawImage(bg, x * k, (y + r) * k, w * k, 2 * k, x + dx, y + r, w, 2); ctx.translate(x, y + h);
} ctx.transform(1, 0, -a / h, 1, 0, 0);
ctx.drawImage(bg, x * k, y * k, w * k, h * k, 0, -h, w, h);
ctx.restore();
} }
}, },
// Lampioni: un alone caldo che si accende (di solito solo di sera, con `phase`). // Lampioni: un alone caldo che si accende (di solito solo di sera, con `phase`).