clone

a browser grid puzzle game where you push words around to rewrite the rules of each level

Refine pause hint timing and mobile controls

Dami committed 72d29c6
commit
72d29c603dcfa5f4fd452f8ba03e5269b1bb11d1
parent
4636e19b640ac577f813f69a7ae959f978bbb50a
author
Dami <dami.etoile@gmail.com>
3 files changed, +39 -5
Msrc/render/menu-motion.js13++++++++++++-
Msrc/render/stage-pause.js13++++++++++---
Mtests/menu-motion.test.js18+++++++++++++++++-
M src/render/menu-motion.js +12 -1
M src/render/stage-pause.js +10 -3
@@ -1,6 +1,6 @@
11 import { drawBoard } from "./board.js";22 import { drawIndex } from "./index.js";3-import { drawKeycap, drawTouchControls } from "./stage-hud.js";3+import { drawKeycap } from "./stage-hud.js";44 import { pauseMotionFrame, pauseMotionLayout } from "./menu-motion.js";55 66 export function wrapCanvasText(ctx, value, maxWidth) {
@@ -19,6 +19,10 @@ export function wrapCanvasText(ctx, value, maxWidth) {
1919 return lines;2020 }2121 22+export function pausePawX(width) {23+ return Math.max(24, width / 2 - 176);24+}25+2226 export function renderPauseScene(ctx, view = {}) {2327 const { width: w, height: h } = view;2428 const {
@@ -83,6 +87,7 @@ export function renderPauseScene(ctx, view = {}) {
8387 ctx.fillStyle = "#FF4B3E";8488 ctx.fillRect(w / 2 - 160, selectedY - 27, 320, pauseMotionLayout.height);8589 }90+ const pawX = pausePawX(w);8691 pauseItems.forEach((item, i) => {8792 const itemMotion = motion.itemProgress[i] ?? 1;8893 const y = itemTop + i * pauseMotionLayout.pitch - (1 - itemMotion) * 22;
@@ -92,13 +97,14 @@ export function renderPauseScene(ctx, view = {}) {
9297 ctx.fillStyle = "#0F0E0D";9398 ctx.font = "800 20px 'Apple Color Emoji', 'Segoe UI Emoji', sans-serif";9499 ctx.textAlign = "right";95- ctx.fillText(i === Math.round(motion.selectedPosition) ? "🐾" : "", w / 2 - 176,100+ ctx.fillText(i === Math.round(motion.selectedPosition) ? "🐾" : "", pawX,96101 y + 1 - (i === Math.round(motion.selectedPosition) ? motion.pawHop : 0));97102 ctx.fillStyle = labelInHighlight ? "#0F0E0D" : "#F2EEE6";98103 ctx.font = "800 13px Recursive, monospace"; ctx.textAlign = "center";99104 ctx.fillText(item.label, w / 2, y + 1 + (i === selected ? motion.pressOffset : 0));100105 ctx.globalAlpha = 1;101106 });107+ ctx.globalAlpha = motion.hintProgress;102108 ctx.textAlign = "left"; ctx.fillStyle = "#8E877C"; ctx.font = "500 11px Recursive, monospace";103109 if (pausedFrom !== "index" && pausedFrom !== "title") {104110 const hintLines = wrapCanvasText(ctx, boardState?.hint || "Choose an action", Math.max(120, w - 64));
@@ -111,5 +117,6 @@ export function renderPauseScene(ctx, view = {}) {
111117 drawKeycap(ctx, "↑↓", "choose", 32, h - 46);112118 drawKeycap(ctx, "ENTER", "select", w / 2 - 4, h - 46, "right");113119 drawKeycap(ctx, "ESC", "back", w - 32, h - 46, "right");114- } else drawTouchControls(ctx, w, h, coarsePointer);120+ }121+ ctx.globalAlpha = 1;115122 }
M tests/menu-motion.test.js +17 -1