prepare for gamepads

This commit is contained in:
Chris Wanstrath 2025-09-29 14:56:40 -07:00
parent 711c0e25ac
commit 815a589b23
3 changed files with 9 additions and 5 deletions

View File

@ -52,10 +52,10 @@ https://wakamaifondue.com/
## Pluto Goals: Phase 2
- [ ] pico8-style games
- [ ] public tunnel for your NOSE webapps
- [ ] public tunnel lives through reboots
- [ ] self updating NOSE server
- [ ] `pub/` static hosting in webapps
- [ ] game/bin/www cartridges
- [ ] upload files to project
- [ ] upload files to projects
- [ ] pico8-style games

View File

@ -193,7 +193,7 @@ export function update(_delta: number, input: InputState) {
paused = !paused
if (paused) return
if (input.justPressed.has(" ")) {
if (input.justPressed.has(" ") || input.justPressed.has("z")) {
rotateShape()
}

View File

@ -49,8 +49,8 @@ export async function handleGameStart(msg: Message) {
canvas = createCanvas()
canvas.focus()
setStatus(msgId, "ok")
canvas.addEventListener("keydown", handleKeydown)
canvas.addEventListener("keyup", handleKeyup)
window.addEventListener("keydown", handleKeydown)
window.addEventListener("keyup", handleKeyup)
window.addEventListener("resize", resizeCanvas)
resizeCanvas()
gameLoop(new GameContext(canvas.getContext("2d")!), game)
@ -137,6 +137,10 @@ function gameLoop(ctx: GameContext, game: Game) {
function endGame() {
running = false
window.removeEventListener("keydown", handleKeydown)
window.removeEventListener("keyup", handleKeyup)
window.removeEventListener("resize", resizeCanvas)
if (oldMode === "tall") browserCommands.mode?.()
canvas.classList.remove("active")