RCWeb Snake App

The RCWeb Snake App (app/snake) is a local-multiplayer arcade game. Implementing the Asymmetric Pattern, it turns a primary display into a shared game board where anyone can scan a QR code to drop in and control their own colored snake simultaneously.

Icon

icon

Screenshot

screenshot

What it does

  • Grid-Based Multiplayer Arena: Recreates classic retro snake mechanics on a strict gridSize matrix. Multiple players compete for the same randomly spawning fruit emojis.
  • Drop-in Play: Players join mid-match effortlessly. Scanning the QR code spawns them instantly in the center of the board with a unique color.
  • Synchronized Scoreboards: Score and life state are maintained on the central screen and heavily pushed backward to individual players' phones so they can monitor their stats locally without looking up.
  • Crash Mechanics: Crashing into another snake's body (or your own) kills your snake, drops your score to zero, and forces a 10-second respawn penalty communicated natively to your controller's UI.

How it works

The core script.js drives a centralized requestAnimationFrame game loop tracking native JavaScript object states rather than DOM elements.

  • Tick Architecture: The game processes physics inside update() restricted by a delay throttle (100ms per tick). Each tick unshifts a new coordinate into an array representing the snake's body blocks and pops the tail off if no food was eaten.
  • Collision Matrices: Snakes perform brute-force $O(n^2)$ array comparisons comparing their [0] head coordinate against every segment of both their own body and every opposing player's body arrays every tick cycle.
  • Asymmetric RPC Mapping: Remote phones trigger strictly predefined public functions (snakeGame.up(), snakeGame.left()). The engine sets snake.nextDx and snake.nextDy directional flags to constrain snake movement strictly to 90-degree locked grid orientations.
  • Backward Feedback: Whenever an event occurs (eating fruit or dying), the engine utilizes rc.send("if (rc.client === '" + i + "') window.updateScore(...)", "snake-control") to surgically target specific players and update their personal phone interfaces.
DocumentationServer TelemetryServer StatsServer HTTP LogServer WebSocket Log