Hackpack Arcade
Keyboard games for the Twilio Hackpack v4 kiosk, served as plain HTML. No React or modules reach the device.
Open on the device
http:///_api/- Kart Dash — Three-lap kart race against five rivals.
- Stack — Falling-block puzzle with hold, ghost piece and levels.
- Overworld — Explore a tile map of rooms, find keys and the hidden treasure.
- Lava Climb — Jump up the platforms before the rising lava catches you.
- Robo 2084 — Blast the robot waves and rescue the last human family.
- Vortex — Spin around the rim of a glowing tube and blast what climbs up it.
- 2048 — Slide the tiles and merge equal numbers to make 2048.
- Chomp Maze — Eat every dot in the maze while four ghosts give chase.
- Brick Hop — Run, jump and stomp through scrolling worlds to the flag.
- Garden Snake — A slow, relaxed snake. Eat berries and grow; the edges wrap around.
More Games (Arcade 2) — Soft Bricks, Sweeper, Echo, Pairs, Lights Out, Slide 15, Four in a Row and Tic-Tac-Toe. The menu links there at the bottom.
Plain http on purpose, so the device needs no modern TLS. https works too. After one online visit the arcade loads offline from the browser's application cache.
Where things live
backend.js serves every page at /_api/<path>. Its PAGES list names each page's path, title, one-line blurb and script; the menu at /_api/ builds itself from that list. Each game's code is a plain string constant at the bottom (KART_JS, STACK_JS, EXPLORE_JS, LAVA_JS, ROBO_JS, VORTEX_JS, G2048_JS, CHOMP_JS, HOP_JS, SNAKE_JS). Every game script lives in backend.js, because the server only loads that one file and cannot import the others. Each file holds at most 128 KB, so backend.js keeps its game scripts unindented, and new games go in Arcade 2 (jchris/hackpack-arcade-2).
App.jsx is only this page, the one you see on vibes.diy. The device never loads it.
Make it yours
Remix this vibe, then ask in its chat. For example:
- "In backend.js, add a Snake page to PAGES with its own SNAKE_JS, following the device rules."
- "Make Stack start at level 5 and show the next five pieces."
- "Flash the LED bar green when someone wins Kart Dash."
Device rules every page follows
TARGET DEVICE: Twilio Hackpack v4 (Raspberry Pi Zero W, 2018 firmware)
Every page backend.js serves at /_api/<path> runs on this device. App.jsx
(the vibes.diy page) is for people on vibes.diy only; the device never loads
it. When you add or change a page, edit PAGES and its script constant in
backend.js, and keep every page script inside these rules.
BROWSER
- Full-screen kiosk built on WebKitGTK 2.16, about the same as Safari 10.1 (2017).
- ES2017 at most. Avoid: optional chaining (?.), nullish coalescing (??), object
spread, Array.prototype.flat, private class fields, BigInt.
- Use one classic <script>, not type="module". Use XMLHttpRequest, not fetch.
- CSS: flexbox, grid and custom properties are fine. Avoid flex "gap",
aspect-ratio, :is()/:where() and inset.
- Slow CPU (single core, 512 MB RAM): keep the DOM small, prefer one <canvas>,
no large libraries.
SCREEN
- 640 x 480 viewport, no scrolling. Use big, high-contrast text (16px minimum,
20px+ for menu items).
INPUT: joystick and buttons as keys, plus a touch screen (see TOUCH SCREEN)
The hardware controls arrive as ordinary keydown/keyup events:
Control Key e.keyCode e.key
Joystick up ArrowUp 38 "ArrowUp"
Joystick down ArrowDown 40 "ArrowDown"
Joystick left ArrowLeft 37 "ArrowLeft"
Joystick right ArrowRight 39 "ArrowRight"
START Enter 13 "Enter"
SELECT Space 32 " "
A a 65 "a"
B b 66 "b"
X x 88 "x"
Y y 89 "y"
POWER (tap) Escape 27 "Escape"
- Check e.keyCode first and fall back to e.key. Call preventDefault() on these keys.
- The joystick is digital, like arrow keys. A diagonal sends two arrows held
at once, so track key state with a "held" map on keydown/keyup rather than
reacting only to single presses.
- Held keys may auto-repeat keydown. Ignore repeats unless you want them.
- Desktop playtesting: the same keys on a laptop keyboard behave identically.
RESERVED / CAUTION
- POWER: 1 tap = Escape (use it for in-app back; it arrives about 0.4 s after
the tap), 2 taps = home to the launcher (your page never sees it), 3 taps =
toggle the joystick between arrow keys and mouse cursor, hold 3 s = shutdown.
Never ask users to tap POWER more than once or to hold it.
- Show on-screen hints using these button names: START, SELECT, A, B, X, Y,
joystick.
INPUT MODE (persistent; set it on load)
- Call pywebview.api.inputArrow({}) for keyboard/arrow controls (default), or
pywebview.api.inputCursor({}) if your page needs the joystick as a mouse.
- Poll for window.pywebview.api first; it appears shortly after load. Do nothing
if it never appears (desktop testing).
- The mode persists until changed. Users can also flip it with 3 taps of POWER.
- Every page in this vibe already calls inputArrow({}) on load (INPUT_JS).
TOUCH SCREEN
- The screen is a touch screen in mouse mode: a tap arrives as mousedown /
mouseup / click at the tapped point, not as touch events. Make on-screen
buttons tappable (listen for mousedown, map clientX/clientY through
getBoundingClientRect to canvas coordinates) and keep them big, about 48 px
or more. Keep joystick control working too.
CONVENTIONS (match the existing launcher and Arcade)
- Menus: up/down to choose, START or A to confirm, B to go back.
- In games: A = primary action, B = secondary/back, START = pause,
SELECT = alternate action (e.g. boost).
- The page must work fully with keyboard input from the moment it loads, with
nothing to click first.
OPTIONAL: LED BAR (5 RGB LEDs)
Pages loaded in the kiosk can reach the Hackpack's Python API. It appears
shortly after load, so poll for it:
window.pywebview && window.pywebview.api
Calls return Promises and take a single plain object of strings/numbers only
(no booleans or null):
pywebview.api.showLightsParams({demo: 3, repeat: 1}) // built-in pattern 1-37
pywebview.api.lightsOff({})
pywebview.api.setLightIntensity({intensity: 40}) // 0-100, default 15
Patterns: 1 scanner, 2 white swell, 3 rainbow, 12-17 pong colors,
18-23 color waves, 30-37 "OK Go" flashes (32 green, 35 red).
Only one call to the same function may be in flight at once; wait for its
Promise before calling it again. The page must still work when
window.pywebview is missing (e.g. desktop testing).