Browser Pong 1v1
The definitive, physics-based arcade table tennis simulator. Features reactive AI, vector collision physics, touch controls, and tournament bracket generation.
About
This tool is a high-fidelity simulation of the classic arcade table tennis experience, engineered directly in the browser using the HTML5 Canvas API. Unlike simple clones, this implementation utilizes a robust vector-based physics engine to handle collision detection, momentum transfer, and friction simulation.
The system features a predictive Artificial Intelligence that calculates ball trajectory based on current velocity vectors v, rather than simple Y-axis tracking. This prevents the "unbeatable AI" syndrome by introducing human-like reaction delays and error margins modeled on Gaussian distributions. The Spin Mechanic dynamically alters the reflection angle θ based on the paddle's vertical velocity at the moment of impact, adding depth to the gameplay.
Designed for immediate utility, the tool includes a comprehensive Tournament Generator for organizing office or group brackets, and a debugging layer that visualizes the mathematical trajectory of the ball in real-time.
Formulas
The core mechanic relies on the Relative Intersect Y reflection model. Unlike optical reflection, Pong physics depends on where the ball hits the paddle.
This normalized value (ranging from -1 to 1) determines the bounce angle θ:
Where θmax is typically 75° (or 5π/12 radians). This allows players to control aim by hitting the edges of the paddle.
Reference Data
| Parameter | Symbol | Default Value | Physics Implication |
|---|---|---|---|
| Base Velocity | v0 | 600 px/s | Initial speed of the ball upon service. |
| Max Velocity | vmax | 1200 px/s | Terminal velocity cap to prevent frame tunneling. |
| Reflection Coeff | k | 1.05 | Speed multiplier applied after every paddle collision (Energy injection). |
| Paddle Friction | μ | 0.2 | Influence of paddle movement on ball vertical angle (Spin). |
| AI Reaction Delay | tr | 150 ms | Simulated neural latency for the computer opponent. |
| Frame Rate | f | 60 Hz | Target render frequency for smooth physics integration. |
| Aspect Ratio | r | 16:9 | Canvas coordinate space scaling factor. |
| Dead Zone | d | 5 px | Threshold for collision resolution to prevent sticking. |