Neon Snake
Cyberpunk retro arcade of classic Snake with real-time global leaderboard and synthesized audio.
Modern Cyberpunk neon reimplementation of classic Snake, built purely with HTML5 Canvas and Vanilla JavaScript with zero framework dependencies. Features a procedural 8-bit chiptune audio synth running directly in browser memory via Web Audio API and real-time serverless high-score leaderboard synchronization backed by Supabase (PostgreSQL).
System Objectives
Recreate the retro arcade experience of classic Snake with a Cyberpunk aesthetic and neon visual effects on HTML5 Canvas.
Implement real-time global persistence for the high-score leaderboard without dedicated backend servers using Supabase PostgreSQL.
Design a procedural 8-bit audio synth engine running directly in browser memory via Web Audio API with zero external audio assets.
Demonstrate the power of pure frontend web development (Vanilla JS ES6+) achieving a smooth deterministic 60 FPS Game Loop.
Key Capabilities & Modules
Full-Swipe Touch Ergonomics: optional D-Pad toggle to gain up to 160 px extra mobile board space, native haptic feedback, and animated 3-2-1 countdown upon resume.
60 FPS Game Loop: ultra-smooth HTML5 Canvas render loop featuring progressive velocity scaling and precision grid collisions.
Overclock Combo & Hyper-Dash: multiply score up to x8 by chaining catches in under 4s and voluntarily boost velocity for double points.
4 Game Modes: 10-level Arcade Overdrive, deterministic Wordle-style Daily Challenge, 90s Time Attack, and relaxing Zen Mode.
4 Nodes & Fair Telegraphing: standard data, bonus golden core, cryo slow-down, and ghost protocol with visual firewall warnings.
Skins Hangar & Medals: 5 unlockable merit Cyber-Skins, 6 collectible medals, and downloadable PNG Cyber-Agent card.
100% Offline PWA & Secure Supabase: runs offline, prevents XSS injections, and delivers a hybrid leaderboard with queue sync.
Architecture & Design Specifications
Decoupled client-BaaS architecture: the client is a self-contained HTML5/Canvas game running at 60 FPS in browser memory. Upon game over, it dispatches an asynchronous REST call to Supabase to register high scores governed by Row Level Security (RLS) policies.
🔍 Click diagram to enlarge to fullscreen
Invariant Architectural Principles:
- Pure Frontend Philosophy: zero bloated frameworks, leveraging native 2D Canvas graphics primitives directly.
- Zero-Cost Serverless: cloud-backed global data persistence through managed Backend-as-a-Service (Supabase PostgreSQL).
- Efficient Procedural Audio: sound effects are synthesized at runtime by modulating oscillators and gain nodes in memory.
Technology Stack
FRONTEND
AUDIO
BACKEND
HOSTING
Reference Articles & Architecture Series
This application is fully documented in an engineering series published on the blog:
From Zero to Hero: Create a Cyberpunk Snake Game with Real-Time Ranking using Supabase and Vanilla JS
Remember classic Snake? We’ve brought it to the future with a Cyberpunk aesthetic and connected it to the cloud. In this ‘From …
Read full article →Evolutionary History & Versions (SemVer)
Formal record of releases, feature additions, and security patches:
Universal Tablet Compliance (Samsung/iPad) & Anti-Pull-to-Refresh Protection
- Universal Tablet Support (Samsung Galaxy Tab, iPads): replaced rigid width media queries with pointer: coarse and maxTouchPoints detection, keeping virtual D-Pad active across all tablet sizes.
- Pull-to-Refresh Eradication: global lock via overscroll-behavior: none and active game touchmove guards, preventing accidental page reloads when swiping down.
- Tablet Scaling & Ergonomics: enlarged 56x52px D-Pad buttons and reserved height recalculation in resizeCanvas() to display board and controls without scrolling.
Full-Swipe Touch Ergonomics, Collision Hit-Stop, Board Inspection & 3-2-1 Countdown
- D-Pad / Full-Swipe Mode toggle: switch between virtual d-pad or pure gestures on touch devices, expanding active canvas height by up to 160 px.
- Native haptic feedback (navigator.vibrate): distinct tactile pulses upon eating nodes (15 ms), leveling up (double pulse), and crashing (80 ms), synchronized with sound.
- 450 ms dramatic Hit-Stop and Board Inspection button: highlights exact impact tile and lets player fade the Game Over modal to review the final position.
- Animated 3-2-1-HACK! countdown with synthesized 8-bit beeps when resuming from Pause, preventing accidental high-speed collisions.
Cyber-PWA Gold Compliance, In-App Updates & Optimistic Offline Leaderboard
- PWA Gold compliance: standalone and appinstalled detection to auto-hide install button, and contextual guidance for iOS Safari vs Android/Desktop in ES/EN.
- Reactive in-app updater: interactive v2.2.0 badge checking on visibilitychange, refresh guard in controllerchange and datalaria-snake-v2.2.0 cache.
- Optimistic offline leaderboard: immediate local cache insertion with OFFLINE status badge and automated background sync with Supabase on reconnect (online event).
Full-Viewport Immersive Mode, Anti-Clipping Framing & Hall of Fame Leaderboard
- Immersive Mode (body.is-playing): hides header and secondary navigation during active gameplay to maximize the board up to 720x720 px on desktop and full width on mobile.
- Elastic modal framing (.canvas-overlay) with zero text clipping, removal of duplicate tab emojis, and complete reactive ES/EN translation.
- Visual redesign of the Global Leaderboard (Cyberpunk Hall of Fame) featuring podium cards (Gold, Silver, Bronze), personal KPIs, and active agent highlight.
Inlining syntax patch and mobile PWA compatibility
- Resolved GRID_SIZE identifier collision in inlined script and eliminated startup SyntaxError.
- Added mobile-web-app-capable meta tag to eliminate deprecation warnings in modern browsers.
- Added INV-SNAKE-11 automated test suite for inlined bundle syntax validation with Node.js.
Cyberpunk Overdrive Evolution: Combo, 4 modes, skins, telegraphing and 100% offline PWA
- Overclock Combo x8 system with cooldown timer and active Hyper-Dash boost mechanics.
- 4 game modes: Arcade Overdrive (10 levels), deterministic Daily Challenge, 90s Time Attack, and Zen Mode.
- 4 cyber node types (Data, Golden Core, Cryo, Ghost) and preventative telegraphing for red firewalls.
- Hangar with 5 merit-based Cyber-Skins, 6 medals, and downloadable PNG Cyber-Agent card.
- Single-Source-of-Truth architecture in /apps/snake/ compiled to static/ with 100% offline PWA and shims.
Official Neon Snake release featuring real-time global leaderboard and procedural synth
- Full arcade Canvas game loop implementation at 60 FPS with progressive velocity acceleration.
- Supabase Realtime and PostgreSQL integration for global high-score leaderboard protected by RLS.
- In-browser 8-bit chiptune sound engine synthesized via Web Audio API.
- Virtual touch controls for mobile smartphones and responsive keyboard mapping.
- Frozen state as an arcade showcase and lightweight serverless architecture demonstrator.
Cloud persistence with Supabase and multiplayer high-score table
- SQL schema for snake_scores table and public RLS security policies.
- Reactive subscription to real-time score insertion events.
Initial Canvas 2D game loop and motion prototype
- Basic snake movement, food spawning, and boundary wall collision detection.