No ball. No controller. No limits. A browser-based basketball game where your body IS the controller.
BREAK THE RULES is a hackathon basketball game controlled entirely by real-time AI pose detection. Using your computer's webcam and MediaPipe Holistic, every move you make β dribbles, crossovers, pump fakes, jump shots β is translated directly into in-game actions.
The entire game lives in a single index.html file. No install. No build step. No dependencies to download. Just open it in Chrome.
| Rule | How We Break It |
|---|---|
| You need a controller to play video games | Your body is the controller |
| You need a basketball to play basketball | You mime it with empty hands |
| Physics limits your moves on the court | Physics-defying crossovers & jump shots |
- 7 gesture-controlled actions β dribble, crossover, shoot, pump fake, pass, jump, move
- Real-time AI vision sidebar β live webcam feed with skeleton overlay, velocity bars, gesture history, shoot state machine, cooldown indicators
- AI defender β 4-state AI (GUARDING β CHASING β CONTESTING β STUMBLE) that reacts to your moves
- Physics-based ball β quadratic arc trajectory, rim collision, bounce, motion trail, rotation spin
- 2pt / 3pt detection β shot value determined by your distance from the hoop
- Streak system β consecutive baskets trigger ON FIRE milestones
- Crowd animation β 200 fans wave and light up on every score
- Particle effects + screen flash β on-court confetti on basket
- Web Audio API sounds β synthesized dribble, shoot, squeak, arpeggio score fanfare
- CRT scanline overlay β retro arcade aesthetic
- Responsive scaling β auto-scales to fit any screen size
# Clone the repo
git clone https://github.com/LeSingh1/break-the-rules-basketball-v2.git
cd break-the-rules-basketball-v2
# Serve locally (required for webcam access)
python3 -m http.server 3000
# Then open http://localhost:3000 in ChromeWhy a local server? The
getUserMediawebcam API requires eitherlocalhostor HTTPS β opening the file directly (file://) won't work.
- Allow camera access when prompted
- Stand 4β6 feet from your webcam so your full upper body is visible
- Make sure you have good lighting β MediaPipe works best in well-lit rooms
- Review the gesture guide on the loading screen
- Click ALLOW CAMERA & PLAY and hit the court
| Gesture | Body Movement | Game Action |
|---|---|---|
| Dribble | Pump both hands downward repeatedly | Player dribbles forward |
| Crossover | Sweep one hand across your body midline | Speed burst, defender stumbles for 1.5s |
| Shoot | Raise both hands above shoulders, hold 8 frames | Ball launches in physics arc toward hoop |
| Pump Fake | Start to raise arms, drop before shoulder height | Defender jumps early, you stay grounded |
| Pass | Thrust ONE arm sideways fast (other stays still) | Ball flies to off-screen teammate |
| Jump | Bend knees and physically jump | Player leaps off the court |
| Move | Lean your whole body left or right | Player slides in that direction |
Priority order: SHOOT > JUMP > CROSSOVER > PUMP FAKE > PASS > DRIBBLE > MOVE
The sidebar on the right gives you a real-time view into what the AI is seeing and deciding:
| Panel | Description |
|---|---|
| LIVE TRACKING | Webcam feed with green skeleton, red/blue wrist dots, and full finger bones |
| DETECTED | Current gesture with color coding and one-line detection explanation |
| BODY METRICS | Animated velocity bars (L/R wrist VX/VY), body lean indicator (ββ), state chips |
| SHOOT ENGINE | 4-step state machine (READY β LOAD β FIRE β COOL) lights up as you raise arms |
| COOLDOWNS | Per-gesture ready/cooling indicators |
| MOVE LOG | Timestamped history of every gesture you trigger |
| Technology | Purpose |
|---|---|
| MediaPipe Holistic | 33-point body pose + 21-point hand landmarks at 30fps |
| HTML5 Canvas 2D | Court, characters, ball, particles, HUD β all drawn with JS |
| Web Audio API | Synthesized SFX β no external audio files |
| OffscreenCanvas | Court cached to offscreen canvas for rendering performance |
| Vanilla JS (ES2022) | No framework, no build tool, no bundler |
| Google Fonts | Press Start 2P (pixel HUD) + Chakra Petch (data panels) |
break-the-rules-basketball/
βββ index.html # The entire game β all JS/CSS inline, one file
βββ README.md # This file
βββ LICENSE # MIT License
βββ .gitignore # Git ignore rules
βββ docs/
βββ GESTURE_REFERENCE.md # Detection algorithms & tuning guide
βββ GAME_DESIGN_DOCUMENT.md # Full 22-section technical spec
βββ ITCH_IO_GUIDE.md # itch.io submission checklist & description copy
getUserMedia (webcam)
β
βΌ
MediaPipe Holistic (every 2nd frame for perf)
β
ββ poseLandmarks[33] βββΆ Gesture Engine
ββ leftHandLandmarks[21] β
ββ rightHandLandmarks[21] β
ββ poseHistory[15 frames]
ββ velocity calculations
ββ cooldown system
ββ priority detection
β
βΌ
Game Actions
(SHOOT/JUMP/MOVE...)
β
ββββββββββββ΄βββββββββββ
βΌ βΌ
Game Loop (60fps) AI Sidebar (20fps)
ββββββββββββββββ ββββββββββββββββββββ
β Court render β β miniCam + skeletonβ
β Characters β β Velocity bars β
β Ball physics β β Shoot state mach. β
β Defender AI β β Cooldowns + log β
β Particles β ββββββββββββββββββββ
β HUD β
ββββββββββββββββ
| Gesture | Threshold | Default | Notes |
|---|---|---|---|
| Dribble wrist speed | DRIBBLE_VY_THRESHOLD |
0.015 | Lower = more sensitive |
| Crossover horizontal | CROSSOVER_VX_THRESHOLD |
0.020 | |
| Shoot height | SHOOT_WRIST_ABOVE_SHOULDER |
0.05 | How far above shoulder |
| Shoot hold frames | SHOOT_LOAD_FRAMES |
8 | Frames held before shot fires |
| Pump fake rise | PUMP_FAKE_RISE |
0.05 | Min rise before detection |
| Movement lean | MOVEMENT_VX_THRESHOLD |
0.015 | |
| Pass speed | PASS_VX_THRESHOLD |
0.04 |
All thresholds are in the CONFIG object at the top of index.html.
| Browser | Support |
|---|---|
| Chrome 99+ | β Recommended |
| Firefox 90+ | β Supported |
| Edge 99+ | β Supported |
| Safari | |
| Mobile | β Not supported (needs full body space) |
Hardware: Any webcam. Works best in well-lit environments with a plain background.
- Zip
index.htmlβbreak-the-rules.zip - Upload to itch.io β New Project β Kind: HTML
- Set viewport to 1280 Γ 720
- Enable "Click to play" (required for AudioContext)
- See
docs/ITCH_IO_GUIDE.mdfor full description copy
The game is a single self-contained HTML file β no build step needed.
# Edit index.html and serve
python3 -m http.server 3000
# Or with Node
npx serve .To tune gesture sensitivity, edit the CONFIG object at the top of the <script> tag in index.html.
MIT β see LICENSE
Pixel Forge Hackathon Β· April 2026 Β· Theme: Rules Are Meant To Be Broken