Dentro la Pieve in penombra con le candele accese che tremolano; al tennis della chiesa si entra solo dal cancello verde
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ApqNBvNbNCwXqR2RLo8QJh
This commit is contained in:
+35
-1
@@ -139,7 +139,7 @@ function drawSprite(ctx, { atlas, img }, frame, x, y, scale, facing, size = 1) {
|
||||
ctx.restore();
|
||||
}
|
||||
|
||||
export function render(ctx, game, { hover, spots, debug } = {}) {
|
||||
export function render(ctx, game, { hover, spots, debug, time = performance.now() } = {}) {
|
||||
const scene = game.scene, s = game.state, bg = backgrounds.get(scene.background);
|
||||
if (!bg && scene.background) loadBackground(scene.background);
|
||||
ctx.imageSmoothingEnabled = false;
|
||||
@@ -158,6 +158,7 @@ export function render(ctx, game, { hover, spots, debug } = {}) {
|
||||
if (sheet) queue.push({ y: p.at[1], draw: () => drawSprite(ctx, sheet, game.personPose(p), ...p.at, game.scaleAt(p.at[1]), p.facing ?? 1, p.size) });
|
||||
}
|
||||
for (const q of queue.sort((a, b) => a.y - b.y)) q.draw();
|
||||
drawLights(ctx, scene, time);
|
||||
if (spots) drawSpots(ctx, game);
|
||||
if (debug) drawDebug(ctx, game, debug);
|
||||
if (hover) {
|
||||
@@ -168,6 +169,39 @@ export function render(ctx, game, { hover, spots, debug } = {}) {
|
||||
}
|
||||
}
|
||||
|
||||
// Le scene buie (`shade`: il velo scuro sopra tutto, Andrea compreso) e le fiammelle (`lights`: candele accese).
|
||||
// Ogni fiamma ha due disegni che si alternano a caso, e intorno un alone caldo che pulsa piano.
|
||||
const FLAME_STEP = 140;
|
||||
export function flameFrame(time, i) {
|
||||
const n = Math.floor(time / FLAME_STEP) * 31 + i * 17;
|
||||
return ((n * 2654435761) >>> 0) % 7 < 3 ? 1 : 0;
|
||||
}
|
||||
function drawLights(ctx, scene, time) {
|
||||
if (scene.shade) {
|
||||
ctx.fillStyle = scene.shade;
|
||||
ctx.fillRect(0, 0, WIDTH, HEIGHT);
|
||||
}
|
||||
if (!scene.lights?.length) return;
|
||||
ctx.save();
|
||||
ctx.globalCompositeOperation = 'lighter';
|
||||
scene.lights.forEach(({ at: [x, y], glow = 30 }, i) => {
|
||||
const pulse = 0.85 + 0.15 * Math.sin(time / 260 + i * 1.7);
|
||||
const g = ctx.createRadialGradient(x, y - 2, 0, x, y - 2, glow * pulse);
|
||||
g.addColorStop(0, 'rgba(255, 170, 70, 0.4)');
|
||||
g.addColorStop(1, 'rgba(255, 120, 40, 0)');
|
||||
ctx.fillStyle = g;
|
||||
ctx.fillRect(x - glow, y - 2 - glow, glow * 2, glow * 2);
|
||||
});
|
||||
ctx.restore();
|
||||
scene.lights.forEach(({ at: [x, y] }, i) => {
|
||||
const tall = flameFrame(time, i);
|
||||
ctx.fillStyle = '#ff9a2e';
|
||||
ctx.fillRect(x - 1, y - 3 - tall, 2, 3 + tall);
|
||||
ctx.fillStyle = '#ffe9a0';
|
||||
ctx.fillRect(tall ? x - 1 : x, y - 2 - tall, 1, 2);
|
||||
});
|
||||
}
|
||||
|
||||
// Il pulsante «?»: un segno su ogni cosa che si può toccare, col suo nome. Le uscite in giallo, il resto in bianco.
|
||||
// I nomi non si sovrappongono: placeLabels cerca per ognuno un posto libero vicino al suo segno.
|
||||
function drawSpots(ctx, game) {
|
||||
|
||||
+3
-6
@@ -506,6 +506,9 @@ export const story = {
|
||||
name: 'Dentro la Pieve',
|
||||
map: [56, 39],
|
||||
background: 'assets/scenes/pieve-interno.png',
|
||||
// Penombra, e le sei candele dell'altare accese (Andrea, 24 ottobre).
|
||||
shade: 'rgba(14, 8, 24, 0.62)',
|
||||
lights: [{ at: [284, 157] }, { at: [294, 159] }, { at: [304, 155] }, { at: [336, 155] }, { at: [346, 159] }, { at: [356, 157] }],
|
||||
walk: [[262, 360], [290, 256], [350, 256], [380, 360]],
|
||||
depth: [[256, 0.7], [360, 1.7]],
|
||||
entry: [320, 352],
|
||||
@@ -1294,9 +1297,6 @@ export const story = {
|
||||
{
|
||||
id: 'al_cancello', name: 'dal cancello verde, verso il posticino della Carza', box: [380, 300, 120, 60], at: [440, 330], exit: { scene: 'carza', at: [440, 290], face: 'left' },
|
||||
},
|
||||
{
|
||||
id: 'alla_carza', name: 'verso il ponticino della Carza', box: [470, 140, 120, 130], at: [515, 280], exit: { scene: 'ponticino', at: [400, 350], face: 'up' },
|
||||
},
|
||||
],
|
||||
},
|
||||
// Fra la Fortezza e i cipressi: la stradina fra le vigne, la casa del maestro Bacci, e lassù il Trebbio.
|
||||
@@ -1536,9 +1536,6 @@ export const story = {
|
||||
{
|
||||
id: 'alla_stazione', name: 'a destra, verso la stazione', box: [486, 160, 90, 40], at: [474, 202], exit: { scene: 'stazione', at: [20, 300], face: 'right' },
|
||||
},
|
||||
{
|
||||
id: 'al_tennis', name: 'giù, verso il tennis della chiesa', box: [0, 160, 230, 70], at: [300, 330], exit: { scene: 'tennis_chiesa', at: [515, 280], face: 'left' },
|
||||
},
|
||||
{
|
||||
id: 'alla_carza', name: 'indietro, verso la Pieve', box: [0, 330, 640, 30], at: [400, 354], exit: { scene: 'carza', at: [325, 222], face: 'down' },
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user