All'Ingorgo la folla dipinta salta a tempo: la fascia della gente tagliata in strisce che sobbalzano sul battito, due fasce per scena, dietro piano e davanti forte (Andrea)

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GiECd9RWGMKV7n3K1mdy8T
This commit is contained in:
2026-10-31 13:42:55 +01:00
co-authored by Claude Fable 5.1
parent b10f031133
commit 4fe6bf4649
4 changed files with 47 additions and 6 deletions
+17 -1
View File
@@ -518,6 +518,22 @@ export const EFFECTS = {
},
// Una bandiera dipinta nello sfondo che sventola: a strisce verticali che salgono e scendono, ferme dalla parte
// dell'asta (`pole`: 'left' o 'right') e sempre più mosse verso il lembo libero.
// La folla dell'Ingorgo che salta a tempo (Andrea, 31 ottobre): la fascia di sfondo `area` tagliata in strisce
// verticali larghe `step`, ognuna che sobbalza sul battito (`bpm`) con una fase sua, come teste che vanno su e giù;
// ogni striscia salta un battito sì e uno no, a turno, con un colpo secco in su e una ricaduta.
crowd(ctx, e, time, game) {
const bg = backgrounds.get(game.backdrop());
if (!bg) return;
const k = bg.width / WIDTH, [ax, ay, aw, ah] = e.area, step = e.step ?? 5, amount = e.amount ?? 3;
const beats = time / 60000 * (e.bpm ?? 120);
for (let x = ax; x < ax + aw; x += step) {
const i = (x - ax) / step, b = (beats / 2 + hash(i * 17 + ay)) % 1, jump = b < 0.5 ? Math.sin(b * Math.PI) : 0;
const dy = Math.round(amount * (0.4 + 0.6 * hash(i * 31 + 5)) * jump);
if (!dy) continue;
const w = Math.min(step, ax + aw - x);
ctx.drawImage(bg, x * k, ay * k, w * k, ah * k, x, ay - dy, w, ah);
}
},
cloth(ctx, e, time, game) {
const bg = backgrounds.get(game.backdrop());
if (!bg) return;
@@ -747,7 +763,7 @@ export const EFFECTS = {
ctx.restore();
},
};
const BACKGROUND_EFFECTS = new Set(['sway', 'clouds', 'cloth', 'leafshadow', ...Object.keys(ambientEffects)]);
const BACKGROUND_EFFECTS = new Set(['sway', 'clouds', 'cloth', 'leafshadow', 'crowd', ...Object.keys(ambientEffects)]);
function drawEffects(ctx, game, time, background = false) {
for (const e of game.scene.effects ?? []) {
if (BACKGROUND_EFFECTS.has(e.type) !== background || !onNow(e, game)) continue;