Pong example
Control the paddle with your force-sensing device. Pull to move the paddle; force level maps to position or speed.
This example is a TypeScript port of gdube's pong-js, a JavaScript remake of the Pong game.
Live demo
Source
Stack
- Vite
- TypeScript
- Canvas
Pattern
- Connect to the device and subscribe with
notify()to get real-timedata.current(and optionallydata.distribution?.left/data.distribution?.rightfor split control). - Map force values to paddle position or velocity (e.g. scale
data.currentto Y position). - Run the game loop: update ball, collision with paddles and walls, then render.