# RCWeb Spacewar 3D Control App

The **RCWeb Spacewar 3D Control App** (`app/spacewar3d-c`) is the dedicated smart-cler for the 3D arcade shooter. It operates within the **Asymmetric Pattern**, delivering physical button feedback and synchronized native audio synthesis.

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

## Screenshot
![screenshot](screenshot.png "Spacewar 3D Control App")

## What it does

- **Classic Arcade Interface**: Retains the reliable, latency-free three-button layout (Left, Right, Fire) utilized in previous Spacewar iterations to maintain precision steering over the 3D ships on the main screen.
- **Audio Duplication**: Synthesizes and plays complex mathematical waveforms (like laser blasts and descending minor piano chord explosions) directly out of the phone's speaker in real-time correlation with the 3D action viewed on the primary display.
- **Bi-directional Scores**: Passively listens for WebSocket updates indicating user score bumps or deaths and visually updates its internal LCD-style score tracker interface.

## How it works

The engine relies heavily on syncing browser physics and handling strict mobile browser policy workarounds.

- **Audio Context Priming**: Since Apple Safari and Google Chrome rigidly block all synthetic audio creation unless triggered immediately by a user input, it establishes an invisible `initAudio` listener attached exclusively to the first `touchstart` event on the entire `document` via `{ once: true }`. This guarantees the `AudioContext` is unlocked well before the user attempts to furiously fire their laser.
- **Mathematical Sound Design**: The `playSound('explosion')` function doesn't play a file, it chains multiple `audioCtx.createOscillator()` instances set to `triangle` wave frequencies. It staggers their execution times (`t`, `t+0.2`, `t+0.4`) and modulates their gain using `exponentialRampToValueAtTime` to build a complex, multi-layered sad notification chord perfectly inside native Javascript.
