MindPuck.Web
MindPuck
Move the puck into the goal with your eyes.
There are three control schemes, and F1 steps through them at any time. The one in use is always named at the bottom centre of the screen.
- Magnetic (the default): the puck is pulled to the point you look at. Look where you want it to go and lead it round the obstacles.
- Steer: keep your eyes on the puck. It travels toward the side of it you look at: look at its right edge and it goes right. Look at its centre and it is left alone.
- Repulsor: a reverse black hole. The puck is pushed away from where you look, harder the closer you look. Look behind it to send it forward; look far away and it glides on its own.
Whichever you use, it moves like a puck on an air-hockey table, bounces off everything, and has to come to rest on the amber pad.
This is the web version, drawn with three.js. Eye tracking comes from MindAttic.Webcam, using the webcam of the computer you play on or the camera of a phone. A mouse or a finger can stand in for your eyes.
The same game exists for Unity (MindPuck.Unity) and Unreal (MindPuck.Unreal), with the same rules, physics numbers and level generator.
Run it
MindPuck expects the Webcam repo checked out beside it:
D:\Projects\MindAttic\MindAttic.Webcam D:\Projects\MindAttic\MindPuck.Web
PowerShell:
cd D:\Projects\MindAttic\MindAttic.Webcam npm install npm run build cd D:\Projects\MindAttic\MindPuck.Web npm install npm start
npm start builds the game and serves it from the Webcam bridge, then opens http://localhost:8787/play/. You should see the title card with three ways to play:
- Use this camera: asks for the webcam, then runs a nine-dot calibration. Look at each dot until it fills.
- Use my phone: the phone's camera watches your eyes while you look at this screen. The status line at the bottom shows the address to open on the phone (same Wi-Fi; accept the certificate warning once). Prop the phone at the bottom or top of the screen, facing you, start its camera, then press C here to calibrate.
- Use the pointer: no camera. The mouse or your finger is the gaze point.
For development with live reload, npm run dev serves the game alone on http://localhost:5183. The webcam and pointer work there. For a phone, run the bridge as well (cd D:\Projects\MindAttic\MindAttic.Webcam; npm run bridge).
Controls
| Key | Button | Does |
|---|---|---|
| F1 | Magnetic / Steer / Repulsor | Step to the next control scheme |
| R | Restart | Put the puck back at the start |
| N | Skip | Go to the next level |
| B | Show me | The solver plays the level, showing where it looks |
| C | Calibrate | Run the eye tracking calibration again |
| Esc | Input | Change how you play |
| F | Fullscreen |
The run's seed and level are remembered between visits. To share or replay a run, add them to the address: ?seed=1234&level=5.
How it works
src/core/holds the rules and nothing else: the physics (physics.ts), the level generator (levelgen.ts), route finding (navgrid.ts) and the solver (bot.ts). It has no browser or three.js dependency.src/game/draws the table with three.js and makes the sounds.src/main.tswires the gaze sources, the menu and the game loop together.
Every level is generated from the seed, then played by a solver before you see it. The solver steers the puck with a simulated gaze point that wobbles and lags the way a real eye tracker does. The solver must win in all three modes, or the level is thrown away and another is generated. The solver's time in the mode you are playing is the par shown in the corner. docs/DESIGN.md has the details and every tuning number.
npm run levels prints a run of levels and how the solver did:
level 9 cup obstacles 11 par 7.0s candidates 1 reruns won 5/5 2 ms
Build and test
npm run buildtypechecks and builds todist/.npm testruns the unit tests (vitest) for the physics, collisions, route finding, level generation and the solver.
Pages in this repository
- MindPuck — Project Bible — Move a puck into the goal with your eyes: an air-hockey puck on a table of obstacles, pushed or pulled by where you look, tracked through…
- MindPuck design — This is the reference for the rules. The web, Unity and Unreal versions implement the same thing; src/core/ in this repo is the original…
- MindPuck.Web — Release charter — MindPuck, the canonical web version (TypeScript, three.js): move an air-hockey puck into the goal with your eyes, through a webcam, a…