# RCWeb Snake Pro Control App

The **RCWeb Snake Pro Control App** (`app/snake-pro-c`) is the dedicated analog joystick controller for the upgraded Snake Pro arcade. Staying true to the **Asymmetric Pattern**, it transforms the smartphone into a sophisticated virtual thumbstick for smooth, 360-degree gameplay.

![icon](pwa-512x512.png "Snake Pro Control App Icon")

## Screenshot
![screenshot](screenshot.png "Snake Pro Control App")

## What it does

- **Virtual Analog Joystick**: Features a massive central touch pad. Dragging the center nub accurately captures multi-directional thumb angles and pressure velocity.
- **Direct Variable Speed**: Calculates the physical distance the user dragged the joystick from the center point (`strength`), passing it to the server so players can intentionally speed up or slow down their snake dynamically.
- **Native CSS Theming**: Natively alters deep root-level CSS variables the instant it connects, completely dynamically re-theming the phone's aesthetic to globally match the randomized neon color assigned to them by the base station.
- **Pulsing Achievement Banner**: Contains an interactive pop-up ribbon (`pulseBannerEle`) that snaps onto the screen to announce temporary achievements natively locally ("Nice bite," "Respawn in 3...").

## How it works

The application heavily focuses on mathematical physics tracking over raw DOM `script.js` button events and throttling high-velocity network payloads.

- **Pointer Event Math Matrix**: Uses native `pointerdown`/`pointermove` specifications rather than just touch events. It establishes the physical center of the `touchPadEle` box boundary and calculates raw Cartesian Distance vectors (`Math.hypot(dx, dy)`) as the user drags.
- **Vector Normalization**: It clips (clamps) joystick length parameters strictly to a boundary constraint (`maxRadius`). It mathematically computes absolute unit vectors (`vectorX: -1.0 to 1.0`, `vectorY: -1.0 to 1.0`) so the host engine is completely agnostic to the physical screen width of the controller supplying the data.
- **Throttle Queue Architecture**: Constantly firing network packets on 120Hz polling-rate smartphone glass would severely bottleneck the RCWeb WebSocket frame capacity. The `sendControlState` loop buffers outbound calls (`rc.sendFunctionCall("snake-pro", "snakePro.remoteInput", ...)`), enforcing a strict `controlIntervalMs (100ms)` threshold timeout clamp safely preventing network traffic flooding.
