Snake Lab
Canvas Snake with timed movement, buffered keyboard/touch input, food, growth, collisions, pace changes, and best scores.
- Status
- Archived experiment / live demo
- Last updated
- May 2026
- Controls
- Steer, collect food, avoid walls/body, and survive as pace increases.
- Keyboard
- Arrow/WASD turn, Space/P/Escape pauses, and Enter starts or resumes.
- Touch
- Swipe on the canvas or use the large on-screen direction pad.
- Accessibility
- Score, best score, length, pace, and live run status are readable outside the canvas.
Ready
Snake Lab ready.
Keyboard and touch controls
Keyboard shortcuts
- Arrow keysTurn the snake up, right, down, or left.
- W A S DAlternate direction keys for movement.
- SpaceStart from idle or pause and resume during a run.
- EnterStart or resume when the game is not actively playing.
- P / EscPause or resume a live run.
Touch controls
- SwipeSwipe on the canvas to turn in that direction.
- Direction padUse the four large movement buttons below the canvas.
- Tap canvasStart a run from the idle menu.
Grid state, buffered turns, and pace feedback.
Main state tracks segments, direction, food, score, pace, and run state. One timed step moves, collides, grows, and saves.
Grid movement, input buffering, and compact run feedback.
- Implemented grid state for snake segments, food placement, growth, wall/body collision detection, score, and length.
- Built input buffering for Arrow keys, WASD, swipe gestures, and touch buttons while blocking illegal reverse turns.
- Added pace changes, pause/restart/fullscreen controls, viewport-aware canvas sizing, and local best-score persistence.
The classic Snake rules are the reference point; the rendering, state model, controls, and HUD are custom JavaScript.
Archived experiment with solid grid state.
Solid: deterministic movement, buffered input, collisions, best score, and keyboard/touch controls. Hardening: turn/collision tests, save reset, screen-reader alternatives, and mobile QA.
Static browser game with no runtime secrets.
GitHub Pages serves snake-lab.html, snake-lab.css, and snake-lab.js. No env vars or external APIs beyond browser APIs and LocalStorage. Local: run python -m http.server 8000 and open /snake-lab.html.