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:
+10
-7
@@ -331,17 +331,20 @@ export const EFFECTS = {
|
||||
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) {
|
||||
const bg = backgrounds.get(game.scene.background);
|
||||
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()) {
|
||||
const a = Math.sin(time / (e.speed ?? 900) + i * 1.3) * (e.amount ?? 1.6);
|
||||
for (let r = 0; r < h; r += 2) {
|
||||
const dx = Math.round(a * (1 - r / h));
|
||||
if (dx) ctx.drawImage(bg, x * k, (y + r) * k, w * k, 2 * k, x + dx, y + r, w, 2);
|
||||
}
|
||||
const a = amount * (0.65 * Math.sin(time / 1900 + i * 1.7) + 0.35 * Math.sin(time / 830 + i * 2.9));
|
||||
ctx.save();
|
||||
ctx.imageSmoothingEnabled = true;
|
||||
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`).
|
||||
|
||||
Reference in New Issue
Block a user