Play on your desktop. Steer with your phone. Scan a QR code and your phone becomes a wireless, analog joystick.
- Host โ open the demo on a computer. A glowing QR code + 6-digit code appears.
- Connect โ scan the QR with your phone camera (or type the code). It auto-connects โ no app, no install.
- Play โ tap โถ to start, then tilt the joystick to steer. Push further to go faster.
The snake never stops โ you steer it at any angle (not just up/down/left/right), and speed scales with how far you push the stick. Eat food quickly to build a ๐ฅ combo (up to ร6) before the streak timer drains.
- ๐ฑ Phone-as-controller โ a polished, responsive analog joystick (notch / safe-area aware) streamed to the desktop in near real-time over Firebase.
- ๐ฏ Analog, continuous-angle movement โ steer by angle; magnitude controls speed. No grid-snapping.
- โ๏ธ 2โ3 player versus โ friends scan the same QR to join; one shared fruit, distinct snake colors, bite a rival and you die โ last snake standing wins ("I defeatedโฆ" bragging cards included).
- ๐ฅ Combo streaks โ chain quick eats for a score multiplier, shown as a draining yellow timer badge.
- ๐ Juice โ particle bursts, ripples, floating score pops, and screen shake on impact.
- ๐ Synthesized sound โ Web Audio SFX whose pitch climbs with your combo; one-tap mute.
- ๐ Global leaderboard โ pick a handle and compete worldwide; see "You ranked #N globally" after every run.
- ๐ณ Haptics + loss flash โ the phone buzzes on loss (Android; best-effort iOS) with an on-screen shake where it can't.
- ๐คณ Flex your score โ share to WhatsApp, X, Facebook, or Instagram straight from your phone.
- ๐ฐ๏ธ Resilient sessions โ presence tracking with
onDisconnect, host-takeover reconcile, and stale-player eviction keep multiplayer rounds clean when a phone drops or the host refreshes. - โก Offline-ready PWA โ installable, with a network-first service worker and an "update available" reload prompt.
- ๐ Single-device fallback โ a
localStoragemode kicks in automatically when Firebase isn't available. - ๐ Privacy-first analytics โ Google Analytics 4 is off by default and never loads until you accept the consent banner (it also honors Do-Not-Track / Global Privacy Control). IP-anonymized, tagged desktop-host vs. phone-controller, and it never blocks gameplay.
| Control | Action |
|---|---|
| ๐น๏ธ Joystick | Rotate to steer (any angle) ยท push further to speed up |
| โถ Center button | Start the game (turns into ๐ while playing) |
| โจ๏ธ Space / Enter (desktop) | Restart after a crash |
| ๐ Play Again (phone) | Restart from the game-over share card |
| ๐ Trophy button (desktop) | View the global Top-10 leaderboard |
Vanilla JavaScript (no bundler, no modules) ยท HTML5 Canvas ยท Firebase Firestore (session + game state) + Realtime Database (joystick stream) + Analytics (GA4) ยท PWA (installable, offline shell) ยท Firebase Hosting with auto-deploy via GitHub Actions.
There's no build step โ just serve the static public/ folder.
npm install # dev tooling only: firebase-tools, eslint, vitest, prettier
npm start # โ npx serve -s public (http://localhost:3000)Any static server works too, e.g. python -m http.server 8000 --directory public.
- Open on a desktop-width window to host the game.
- Append
?session=123456to the URL (or open on a phone) to load the controller view in a second tab/device.
npm run lint # ESLint
npm test # Vitest unit tests (tests/)
npm run format # PrettierDeploys are automatic on push to master (GitHub Actions โ firebase deploy --only hosting,firestore,database) โ the site and both security-rule sets ship together; the rules files in this repo are the source of truth.
Plain <script> files share one global scope, loaded in a fixed order โ there's no import graph. The desktop owns the game loop, rendering, and collision; the phone captures the joystick. They pair over a 6-digit code / QR via Firebase, with a localStorage fallback for single-device use.
๐ค Full map for contributors and AI agents lives in CLAUDE.md, with a deeper index under
.agent/.
PRs welcome โ see CONTRIBUTING.md. We use Conventional Commits (feat | fix | refactor | style) and branch as feature/โฆ, bugfix/โฆ, docs/โฆ.
Made with โค๏ธ by Aryaman Godara ยท โญ the repo if you enjoyed it!