# RCWeb Tankwar Control App

The **RCWeb Tankwar Control App** (`app/tankwar-c`) acts as the dedicated driving interface for the Tankwar game, designed under the **Asymmetric Pattern**. It transforms a mobile screen into a dual-thumb complex vector control system.

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

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

## What it does

- **Dual-Thumb Gameplay**: Employs an advanced multi-touch split layout. The left thumb operates a fluid analog drag-joystick for 360-degree driving, while the right thumb operates a dedicated fire button.
- **Variable Movement Strength**: Dragging the joystick slightly near the center moves the tank slowly; pulling it to the absolute edge drives the tank at full velocity, providing granular analog control to the core server.
- **Player Theming**: Dynamically updates the interface CSS color palette (`--player-hue`) directly injecting the specific color ID the host server randomly assigned to the player ensuring no team confusion.

## How it works

The logic primarily revolves around math-heavy pointer event handling and strict bandwidth throttling inside `script.js`.

- **Cartesian Pointer Evaluation**: The `sendTouch` function anchors tracking on continuous pointer drags. It calculates the raw distance from the exact center of the `touchPadEle` bounding box (`Math.hypot(dx, dy)`). It mathematically normalizes these coordinates mathematically to return a clean vector (`-1.0 to 1.0`) across X and Y, alongside a normalized `strength` scalar (0 to 1).
- **Network Traffic Buffering**: Broadcasting 60+ touch-move matrices per second from multiple phones would overwhelm the `comms.js` WebSocket infrastructure. Instead, the logic modifies an internal `outboundState` object locally and implements an external `window.setInterval(flushOutboundState, 100)` heartbeat loop. This guarantees state packets are strictly rate-limited safely to merely 10 per second maximum. 
- **Delta Comparison Filter**: To save further bandwidth, `flushOutboundState` compares the pending outbound network update against a cached `lastSentState` memory block. If the player hasn't moved their thumb or pressed fire, no packets leave the device.
