Il risveglio di nuovo come prima sul computer, con la sfocatura vera, e leggero sul telefono, senza filtri; tutte e due su una tela a parte che c'è solo finché il risveglio dura, così la scena non ne risente (Andrea)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GiECd9RWGMKV7n3K1mdy8T
This commit is contained in:
2026-10-31 11:57:26 +01:00
co-authored by Claude Opus 5.5
parent f7ca286066
commit f57a91ca74
5 changed files with 56 additions and 25 deletions
+19 -1
View File
@@ -182,6 +182,7 @@ export function render(ctx, game, { hover, spots, debug, time = performance.now(
: drawAndrea(ctx, s.x, s.y, game.scaleAt(s.y), s.facing, game.walking ? game.stride / 6 : null);
// Durante il risveglio si guarda dagli occhi di Andrea: lui non si vede.
const pov = game.closeup && game.story.closeups?.[game.closeup.id]?.type === 'risveglio';
if (!pov) risveglioLayer(ctx, false);
const queue = pov ? [] : [{ y: s.y, draw: drawAndreaNow }];
for (const p of game.people()) {
const sheet = sprites.get(p.who);
@@ -886,6 +887,18 @@ function drawDebug(ctx, game, { mouse, points = [], help }) {
ctx.restore();
}
// La tela del risveglio (risveglio.js): una tela a parte sopra la scena, che c'è solo finché il risveglio dura.
function risveglioLayer(ctx, on = true) {
if (typeof document === 'undefined' || !ctx.canvas?.after) return null;
let layer = document.getElementById('risveglio');
if (!on) { layer?.remove(); return null; }
if (!layer) {
layer = Object.assign(document.createElement('canvas'), { id: 'risveglio', width: WIDTH, height: HEIGHT });
ctx.canvas.after(layer);
}
return layer.getContext('2d');
}
// --- Il primo piano di un libro (story.closeups, game.closeup): la scena si oscura, le mani alzano il libro dal basso.
// Le immagini hanno etichetta e pagine vuote: i testi si scrivono qui, nitidi. Una pagina sola gira, a fisarmonica
// sulla piega; sotto c'è già l'ultima pagina.
@@ -924,7 +937,12 @@ function drawCloseup(ctx, game, time) {
// L'incantesimo va sopra la scena (con Andrea dentro), già disegnata.
if (def.type === 'incanto') { drawIncanto(ctx, c); return; }
// Il risveglio, visto da dentro gli occhi: anche lui sopra la scena già disegnata.
if (def.type === 'risveglio') { drawRisveglio(ctx, c, backgrounds.get(game.backdrop())); return; }
// Sul telefono (schermo touch) la versione leggera, senza filtri; sul computer quella con la sfocatura vera.
if (def.type === 'risveglio') {
const layer = risveglioLayer(ctx), light = matchMedia('(pointer: coarse)').matches;
if (layer) drawRisveglio(layer, c, backgrounds.get(game.backdrop()), { light });
return;
}
// Il telefonino del Barone: sale come il libro, e il sito nello schermo si allarga a tutta la scena.
if (def.type === 'telefono') {
const pic = src => { if (!backgrounds.has(src)) loadBackground(src); return backgrounds.get(src); };