Sfondi veri di Piazza Colonna, Fortezza e Trebbio, aiuti del castello, Docker
Tre scene con aree calpestabili e punti cliccabili ricavati dagli sfondi, tools/prepare_background.py per ridurli a 640x360, il castello del Trebbio che dà indizi in base ai progressi, container nginx sulla porta 8080. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+14
-1
@@ -56,9 +56,22 @@ export function drawAndrea(ctx, x, y, scale, facing, walkPhase) {
|
||||
ctx.restore();
|
||||
}
|
||||
|
||||
// Sfondi delle scene, caricati una volta sola. Finché un'immagine non c'è si vedono le forme `art`.
|
||||
const backgrounds = new Map();
|
||||
export function loadBackgrounds(story) {
|
||||
return Promise.all(Object.values(story.scenes).filter(s => s.background).map(s => new Promise(resolve => {
|
||||
const img = new Image();
|
||||
img.onload = () => { backgrounds.set(s.background, img); resolve(true); };
|
||||
img.onerror = () => resolve(false);
|
||||
img.src = s.background;
|
||||
})));
|
||||
}
|
||||
|
||||
export function render(ctx, game, { hover } = {}) {
|
||||
const scene = game.scene, s = game.state;
|
||||
const scene = game.scene, s = game.state, bg = backgrounds.get(scene.background);
|
||||
ctx.imageSmoothingEnabled = false;
|
||||
ctx.clearRect(0, 0, WIDTH, HEIGHT);
|
||||
if (bg) ctx.drawImage(bg, 0, 0, WIDTH, HEIGHT);
|
||||
for (const shape of scene.art ?? []) drawShape(ctx, shape);
|
||||
for (const h of game.hotspots()) for (const shape of h.art ?? []) drawShape(ctx, shape);
|
||||
const phase = game.walking ? (s.x + s.y) / 6 : null;
|
||||
|
||||
Reference in New Issue
Block a user