Brick Blitz
Add a pause key (P / Esc) #2
openpixelpat wants to merge changes from pixelpat/brick-blitz · 15 hours ago
1 file changed · +2 −0
modifiedgame.js
@@ −81,6 +81,7 @@
8181
8282 addEventListener("keydown", (e) => {
8383 keys[e.key] = true;
84+ if (e.key === "p" || e.key === "Escape") { paused = !paused; return; }
8485 if (e.key === " " || e.key === "Enter" || e.key === "ArrowUp") { press(); e.preventDefault(); }
8586 });
8687 addEventListener("keyup", (e) => (keys[e.key] = false));
@@ −241,6 +242,7 @@
241242 };
242243 if (state === "title") center("BRICK BLITZ", "Tap or press Space to start", `Move: mouse, touch or ← → · Best: ${best()}`);
243244 if (state === "serve") { ctx.fillStyle = "#c9c3ff"; ctx.font = "600 18px system-ui"; ctx.textAlign = "center"; ctx.fillText("Tap / Space to launch", W / 2, H - 90); }
245+ if (paused && state !== "title") center("PAUSED", "Press P to resume");
244246 if (state === "over") center("GAME OVER", `Score ${score} · Best ${best()}`, "Tap or press Space to play again");
245247 }
246248