Pulsante «?» (o H) che mostra per qualche secondo cosa si può toccare; mappa che si scorre sul telefono

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017egeN2amL84ErjfgQFtEDn
This commit is contained in:
2026-10-23 21:57:25 +02:00
co-authored by Claude Opus 5.5
parent a5a6834a37
commit c0d643d05d
5 changed files with 46 additions and 6 deletions
+25 -1
View File
@@ -102,7 +102,7 @@ function drawSprite(ctx, { atlas, img }, frame, x, y, scale, facing, size = 1) {
ctx.restore();
}
export function render(ctx, game, { hover } = {}) {
export function render(ctx, game, { hover, spots } = {}) {
const scene = game.scene, s = game.state, bg = backgrounds.get(scene.background);
ctx.imageSmoothingEnabled = false;
ctx.clearRect(0, 0, WIDTH, HEIGHT);
@@ -119,6 +119,7 @@ export function render(ctx, game, { hover } = {}) {
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();
if (spots) drawSpots(ctx, game);
if (hover) {
ctx.strokeStyle = 'rgba(255,255,255,0.35)';
ctx.setLineDash([3, 3]);
@@ -126,3 +127,26 @@ export function render(ctx, game, { hover } = {}) {
ctx.setLineDash([]);
}
}
// Il pulsante «?»: un segno su ogni cosa che si può toccare, col suo nome. Le uscite in giallo, il resto in bianco.
function drawSpots(ctx, game) {
ctx.save();
ctx.font = '6px "Press Start 2P", monospace';
ctx.textAlign = 'center';
ctx.textBaseline = 'bottom';
for (const h of game.hotspots()) {
const [x, y, w, hh] = h.box, cx = Math.round(x + w / 2), cy = Math.round(y + hh / 2);
const color = h.exit ? '#ffd27a' : '#ffffff';
ctx.fillStyle = 'rgba(0,0,0,0.55)';
ctx.fillRect(cx - 4, cy - 4, 9, 9);
ctx.fillStyle = color;
ctx.fillRect(cx - 3, cy - 3, 7, 7);
ctx.lineWidth = 3;
ctx.strokeStyle = '#000';
// Il nome resta dentro la scena anche per le uscite sui bordi.
const half = ctx.measureText(h.name).width / 2, tx = Math.max(half + 2, Math.min(WIDTH - half - 2, cx)), ty = Math.max(10, cy - 6);
ctx.strokeText(h.name, tx, ty);
ctx.fillText(h.name, tx, ty);
}
ctx.restore();
}