Motion Shot
Languages
Simple English (Simple English)
Game Diversifiers
Hands Off
The World is Alive
Let's Jam!
Diverse
Platforms
Linux / Unix
Mac OS
MS Windows
Web
About
๐ฎ Motion Shot
What It Is
A hand-tracking bubble shooter game that uses your webcam to detect hand gestures. You control a slingshot by pinching your thumb and index finger, pulling back, and releasing to shoot bubbles.
Core Gameplay
๐ค Pinch - Grab the slingshot ball
โ Pull - Drag back to aim and charge power
๐๏ธ Release - Let go to fire at the bubble grid
๐ฏ Goal - Match 3+ same-colored bubbles to pop them and score points
Key Features
Feature Description
Hand Tracking Uses MediaPipe Hands via webcam for gesture detection
AI Strategy Gemini AI provides real-time targeting hints
Combo System Chain matches within 3 seconds for multiplier bonuses
Power Gauge Visual feedback showing shot strength (0-100%)
Level Progression Clear bubbles to advance through levels
Synthesized Audio Dynamic background music and sound effects
Controls
Primary: Hand gestures (pinch to grab, pull to aim, release to shoot)
Fallback: Mouse/touch for devices without camera
Tech Stack
React + TypeScript - UI framework
Canvas 2D - Game rendering
MediaPipe Hands - Hand tracking AI
Gemini AI - Strategic hints
Web Audio API - Procedural music/SFX
The Story Behind It
The game celebrates the evolution of play โ from ancient stone-throwing to modern gesture control. It's a "bridge between past and present," returning the power of natural hand movements to gaming.
What It Is
A hand-tracking bubble shooter game that uses your webcam to detect hand gestures. You control a slingshot by pinching your thumb and index finger, pulling back, and releasing to shoot bubbles.
Core Gameplay
๐ค Pinch - Grab the slingshot ball
โ Pull - Drag back to aim and charge power
๐๏ธ Release - Let go to fire at the bubble grid
๐ฏ Goal - Match 3+ same-colored bubbles to pop them and score points
Key Features
Feature Description
Hand Tracking Uses MediaPipe Hands via webcam for gesture detection
AI Strategy Gemini AI provides real-time targeting hints
Combo System Chain matches within 3 seconds for multiplier bonuses
Power Gauge Visual feedback showing shot strength (0-100%)
Level Progression Clear bubbles to advance through levels
Synthesized Audio Dynamic background music and sound effects
Controls
Primary: Hand gestures (pinch to grab, pull to aim, release to shoot)
Fallback: Mouse/touch for devices without camera
Tech Stack
React + TypeScript - UI framework
Canvas 2D - Game rendering
MediaPipe Hands - Hand tracking AI
Gemini AI - Strategic hints
Web Audio API - Procedural music/SFX
The Story Behind It
The game celebrates the evolution of play โ from ancient stone-throwing to modern gesture control. It's a "bridge between past and present," returning the power of natural hand movements to gaming.
Technology Notes
# ๐ฏ Motion Shot - Complete Game Documentation
<div align="center">
## AI-Powered Bubble Shooter with Hand Gesture Control
**"From Stones to Gestures: A Story of Play Across Time"**
---
</div>
## Table of Contents
1. [Project Overview](#1-project-overview)
2. [The Story](#2-the-story)
3. [How It's Built](#3-how-its-built)
4. [How It Works](#4-how-it-works)
5. [How to Play](#5-how-to-play)
6. [Game Features](#6-game-features)
7. [Technical Architecture](#7-technical-architecture)
---
## 1. Project Overview
### What is Motion Shot?
Motion Shot is an innovative **AI-powered bubble shooter game** that bridges ancient human play with modern technology. Using hand gestures captured through your webcam, you control a slingshot just like our ancestors threw stones โ but now the target is digital.
### The Philosophy
> "The hand that once shaped history is now shaping the future of gaming."
We believe technology should enhance, not replace, the natural human connection to play. Motion Shot brings back the physical joy of throwing while adding AI-powered strategy.
### Key Features
| Feature | Description |
|---------|-------------|
| ๐๏ธ **Hand Tracking** | MediaPipe Hands SDK tracks 21 hand landmarks for precise gesture recognition |
| ๐ง **AI Strategy (Gemini)** | Real-time tactical analysis and shot recommendations |
| ๐จ **6-Color Scoring** | Strategic scoring with different point values per color (100-500 pts) |
| ๐ฅ **Combo System** | Chain matches for multiplier bonuses up to 5x |
| ๐ต **Dynamic Audio** | Synthesized background music and contextual sound effects |
| ๐ **Narrative Experience** | Cinematic story introduction about the evolution of play |
| โก **Real-time Physics** | Smooth ball trajectories with wall bouncing and collision detection |
---
## 2. The Story
### From Stones to Gestures: A Story of Play Across Time
**PROLOGUE - The Dawn of Play**
Long ago, before electricity, before screens, people played using only their bodies, their minds, and nature. The hand was the main tool โ to throw, to aim, to defend, and to survive.
**CHAPTER I - Lessons of Fire**
Children threw stones to hit targets. Warriors trained their hands and eyes. Games were lessons of life โ teaching focus, patience, and skill.
**CHAPTER II - The Forgetting**
Games moved from fields to boards, then to screens. Buttons replaced hands. Controllers replaced movement. The natural connection between body and play was slowly forgotten.
**CHAPTER III - The Return**
With hand-motion control, the hand becomes the interface again. No buttons. No weapons. Just gestures โ pinch, pull, and release.
**EPILOGUE - Your Journey Begins**
This is not just a game. Technology did not replace humanity โ it returned power to it.
---
## 3. How It's Built
### Technology Stack
```
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ FRONTEND STACK โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ React 18+ โ UI Components & State Management โ
โ TypeScript 5.x โ Type Safety & Code Quality โ
โ Vite 6 โ Fast Build Tool & Dev Server โ
โ Tailwind CSS โ Utility-First Styling โ
โ Lucide React โ Icon Library โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ AI & VISION โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ MediaPipe Hands โ Real-time Hand Tracking (21 pts) โ
โ Google Gemini AI โ Vision AI for Strategy Analysis โ
โ @google/genai โ Official Gemini SDK โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ AUDIO โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Web Audio API โ Synthesized Music & Sound Effects โ
โ Procedural Audio โ Dynamic Background Music โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
```
### Project Structure
```
Motion-Shot/
โโโ App.tsx # Root component - Screen flow management
โโโ index.tsx # Application entry point
โโโ index.html # HTML template with MediaPipe CDN scripts
โโโ types.ts # TypeScript type definitions
โโโ vite.config.ts # Vite configuration
โโโ package.json # Dependencies & scripts
โ
โโโ components/
โ โโโ StoryPage.tsx # Cinematic story introduction
โ โ # - 5-chapter narrative
โ โ # - Particle effects
โ โ # - Animated transitions
โ โ
โ โโโ GameLauncher.tsx # Professional game menu
โ โ # - Tutorial/How to Play
โ โ # - Audio controls
โ โ # - Feature highlights
โ โ
โ โโโ GeminiSlingshot.tsx # Main game component (~1500 lines)
โ # - Game loop & rendering
โ # - Physics simulation
โ # - Hand tracking integration
โ # - Combo system
โ # - UI overlays
โ
โโโ services/
โ โโโ geminiService.ts # AI service layer
โ โ # - Gemini API integration
โ โ # - Strategic hint generation
โ โ # - Response parsing
โ โ
โ โโโ soundService.ts # Audio engine
โ # - Procedural music synthesis
โ # - UI sounds
โ # - Game sound effects
โ
โโโ docs/
โโโ GAME_DOCUMENTATION.md # This file
โโโ ARCHITECTURE.md # Technical architecture details
โโโ API_REFERENCE.md # Type definitions & functions
โโโ DEPLOYMENT.md # Hosting guide
โโโ CONTRIBUTING.md # Contribution guidelines
```
---
## 4. How It Works
### System Data Flow
```
โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโ
โ WEBCAM โโโโโถโ MediaPipe โโโโโถโ Game Loop โ
โ INPUT โ โ Hands SDK โ โ (60 FPS) โ
โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ
โผ โผ
โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ
โ Hand Position โ โ Canvas Render โ
โ Detection โ โ - Video BG โ
โ - 21 Landmarks โ โ - Bubble Grid โ
โ - Pinch Detect โ โ - Slingshot โ
โโโโโโโโโโโโโโโโโโโโ โ - Particles โ
โ โ - Ball Trail โ
โผ โโโโโโโโโโโโโโโโโโโโ
โโโโโโโโโโโโโโโโโโโโ โ
โ Slingshot โ โ
โ Mechanics โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ - Power Gauge โ โ
โ - Tension FX โ โโโโโโโโโโโโโโโโโโโโโโโค
โ - Release โ โ โ
โโโโโโโโโโโโโโโโโโโโ โ โ
โ โ โ
โผ โ โ
โโโโโโโโโโโโโโโโโโโโ โผ โ
โ Physics โ โโโโโโโโโโโโโโโโโโโโ โ
โ Simulation โ โ Screenshot โ โ
โ - Trajectory โ โ Capture โ โ
โ - Collision โ โ (480px JPEG) โ โ
โ - Ball Trail โ โโโโโโโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโ โ โ
โ โผ โ
โผ โโโโโโโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโ โ Gemini AI โ โ
โ Match Check โ โ Vision API โ โ
โ - Flood Fill โ โ - Analyze Grid โ โ
โ - Combo System โ โ - JSON Responseโ โ
โ - Score Update โ โโโโโโโโโโโโโโโโโโโโ โ
โ - Particles โ โ โ
โโโโโโโโโโโโโโโโโโโโ โ โ
โ โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโ
```
### Key Mechanics
#### 1. Hand Tracking & Pinch Detection
```
MediaPipe detects 21 hand landmarks. The game uses:
- Point 4: Thumb tip
- Point 8: Index finger tip
Pinch Distance = โ[(thumb.x - index.x)ยฒ + (thumb.y - index.y)ยฒ]
If Pinch Distance < 0.05 โ User is "grabbing" the ball
```
#### 2. Power Gauge System
```
Pull Distance determines shot power:
- 0-30%: Green (Weak shot)
- 30-60%: Yellow (Medium shot)
- 60-80%: Orange (Strong shot)
- 80-100%: Red (Maximum power)
Visual Feedback:
- Slingshot band changes color
- Tension rings pulse around ball
- Screen vibrates at high tension
- Power percentage displayed
```
#### 3. Combo System
```
Combos trigger when multiple matches occur within 3 seconds:
Combo Level โ Multiplier โ Visual Effect
โโโโโโโโโโโโโผโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโ
1x โ 1.0x โ Normal
2x โ 1.5x โ "COMBO x2!" text
3x โ 2.0x โ Screen glow
4x โ 2.5x โ Enhanced particles
5x+ โ 3.0x โ Screen shake + flash
```
#### 4. Bubble Matching (Flood Fill Algorithm)
```
When ball snaps to grid:
1. Find all connected same-color bubbles
2. Use hex-grid neighbor detection (6 neighbors)
3. If cluster >= 3 bubbles:
- Deactivate bubbles
- Create explosion particles
- Calculate score: (base ร combo ร bubble_count)
- Show floating score animation
```
### Scoring System
| Color | Points per Bubble | Strategic Value |
|-------|------------------|-----------------|
| ๐ด Red | 100 | Low - Common, easy targets |
| ๐ต Blue | 150 | Low-Medium |
| ๐ข Green | 200 | Medium |
| ๐ก Yellow | 250 | Medium-High |
| ๐ฃ Purple | 300 | High - Valuable targets |
| ๐ Orange | 500 | Highest - Rare, priority target |
**Combo Multipliers**: 1x โ 1.5x โ 2x โ 2.5x โ 3x (max)
---
## 5. How to Play
### Setup Requirements
- **Desktop computer** with webcam
- **Modern browser** (Chrome, Firefox, Edge)
- **Well-lit environment** for hand tracking
- **Node.js 18+** for development
### Installation
```bash
# 1. Clone and install
git clone https://github.com/Sengwamana/Motion-Shot.git
cd Motion-Shot
npm install
# 2. Configure API Key (for AI features)
# Create .env file with:
GEMINI_API_KEY=your_gemini_api_key_here
# 3. Start the game
npm run dev
# 4. Open http://localhost:3000
```
### Game Controls
```
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ GAME CONTROLS โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โ
โ 1. SHOW YOUR HAND ๐๏ธ โ
โ Position your hand in view of the webcam โ
โ โ
โ 2. PINCH TO GRAB ๐ค โ
โ Touch thumb to index finger near the slingshot ball โ
โ โ
โ 3. PULL BACK TO AIM ๐ฏ โ
โ While pinching, move hand backward to stretch slingshot โ
โ - Watch the power gauge (0-100%) โ
โ - Band color indicates power level โ
โ - Tension rings show charge intensity โ
โ โ
โ 4. RELEASE TO FIRE ๐ โ
โ Open your fingers to launch the ball โ
โ - Ball leaves glowing trail while flying โ
โ โ
โ 5. MATCH BUBBLES ๐ฅ โ
โ Hit 3+ same-colored bubbles to pop them โ
โ - Chain matches quickly for combo multipliers โ
โ โ
โ 6. FOLLOW AI HINTS ๐ง โ
โ Watch for Gemini's strategic recommendations โ
โ - Laser sight shows suggested target โ
โ โ
โ ALTERNATIVE: Mouse/Touch controls available as fallback โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
```
### Game Flow
```
โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ
โ STORY โโโโโถโ LAUNCHER โโโโโถโ GAME โ
โ PAGE โ โ MENU โ โ PLAY โ
โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ
โ โ โ
โ 5 Chapters โ How to Play โ Levels
โ Skip option โ Audio toggle โ Score
โ Navigation โ Start button โ Combos
โโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโ
```
---
## 6. Game Features
### Visual Effects
| Effect | Description |
|--------|-------------|
| **Ball Trail** | Glowing trail follows the ball during flight |
| **Tension Rings** | Pulsing circles around ball when pulling back |
| **Power Glow** | Ball glows brighter at higher power |
| **Floating Scores** | Animated score popups with combo multipliers |
| **Screen Shake** | Camera shake on big combos |
| **Particle Explosions** | Colorful particles when bubbles pop |
| **Release Flash** | Screen flash effect when firing |
### Audio System
| Sound Type | Trigger |
|------------|---------|
| **Background Music** | Procedural synthesized ambient music |
| **UI Click** | Button interactions |
| **Ball Launch** | Releasing the slingshot |
| **Bubble Pop** | Matching bubbles |
| **Combo Sound** | Achieving combo multipliers |
| **Game Start** | Starting the game |
| **Level Complete** | Clearing a level |
### AI Integration (Gemini)
The game integrates Google's Gemini AI for strategic assistance:
- **Board Analysis**: AI analyzes the current bubble configuration
- **Target Recommendation**: Suggests optimal bubble clusters to target
- **Color Selection**: Recommends which color ball to use
- **Strategic Rationale**: Explains why a particular move is beneficial
- **Laser Sight**: Visual indicator pointing to AI's recommended target
---
## 7. Technical Architecture
### State Management
| State Type | Usage | Purpose |
|------------|-------|---------|
| `useState` | UI elements | Score, hints, game state, level |
| `useRef` | Game physics | Ball position, velocity, bubbles (60fps) |
### Audio Engine
The sound service uses Web Audio API for procedural audio:
- **Oscillator-based synthesis** for all sounds
- **Chord progressions** for ambient music
- **Envelope generators** for dynamic volume
- **No audio files** - everything is synthesized in real-time
### Performance Optimizations
- **RequestAnimationFrame** for smooth 60fps rendering
- **Canvas layering** to minimize redraw
- **Substep collision detection** for fast-moving balls
- **Debounced AI calls** to prevent API spam
- **Image compression** for AI screenshots (480px JPEG 60%)
---
## Credits
**Motion Shot** - A game about the timeless connection between human hands and play.
- **Hand Tracking**: MediaPipe by Google
- **AI Strategy**: Google Gemini
- **Audio**: Web Audio API
- **Framework**: React + TypeScript + Vite
---
<div align="center">
*"The hand that once shaped history is now shaping the future of gaming."*
๐ฏ **Motion Shot** ๐ฏ
</div>
<div align="center">
## AI-Powered Bubble Shooter with Hand Gesture Control
**"From Stones to Gestures: A Story of Play Across Time"**
---
</div>
## Table of Contents
1. [Project Overview](#1-project-overview)
2. [The Story](#2-the-story)
3. [How It's Built](#3-how-its-built)
4. [How It Works](#4-how-it-works)
5. [How to Play](#5-how-to-play)
6. [Game Features](#6-game-features)
7. [Technical Architecture](#7-technical-architecture)
---
## 1. Project Overview
### What is Motion Shot?
Motion Shot is an innovative **AI-powered bubble shooter game** that bridges ancient human play with modern technology. Using hand gestures captured through your webcam, you control a slingshot just like our ancestors threw stones โ but now the target is digital.
### The Philosophy
> "The hand that once shaped history is now shaping the future of gaming."
We believe technology should enhance, not replace, the natural human connection to play. Motion Shot brings back the physical joy of throwing while adding AI-powered strategy.
### Key Features
| Feature | Description |
|---------|-------------|
| ๐๏ธ **Hand Tracking** | MediaPipe Hands SDK tracks 21 hand landmarks for precise gesture recognition |
| ๐ง **AI Strategy (Gemini)** | Real-time tactical analysis and shot recommendations |
| ๐จ **6-Color Scoring** | Strategic scoring with different point values per color (100-500 pts) |
| ๐ฅ **Combo System** | Chain matches for multiplier bonuses up to 5x |
| ๐ต **Dynamic Audio** | Synthesized background music and contextual sound effects |
| ๐ **Narrative Experience** | Cinematic story introduction about the evolution of play |
| โก **Real-time Physics** | Smooth ball trajectories with wall bouncing and collision detection |
---
## 2. The Story
### From Stones to Gestures: A Story of Play Across Time
**PROLOGUE - The Dawn of Play**
Long ago, before electricity, before screens, people played using only their bodies, their minds, and nature. The hand was the main tool โ to throw, to aim, to defend, and to survive.
**CHAPTER I - Lessons of Fire**
Children threw stones to hit targets. Warriors trained their hands and eyes. Games were lessons of life โ teaching focus, patience, and skill.
**CHAPTER II - The Forgetting**
Games moved from fields to boards, then to screens. Buttons replaced hands. Controllers replaced movement. The natural connection between body and play was slowly forgotten.
**CHAPTER III - The Return**
With hand-motion control, the hand becomes the interface again. No buttons. No weapons. Just gestures โ pinch, pull, and release.
**EPILOGUE - Your Journey Begins**
This is not just a game. Technology did not replace humanity โ it returned power to it.
---
## 3. How It's Built
### Technology Stack
```
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ FRONTEND STACK โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ React 18+ โ UI Components & State Management โ
โ TypeScript 5.x โ Type Safety & Code Quality โ
โ Vite 6 โ Fast Build Tool & Dev Server โ
โ Tailwind CSS โ Utility-First Styling โ
โ Lucide React โ Icon Library โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ AI & VISION โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ MediaPipe Hands โ Real-time Hand Tracking (21 pts) โ
โ Google Gemini AI โ Vision AI for Strategy Analysis โ
โ @google/genai โ Official Gemini SDK โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ AUDIO โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Web Audio API โ Synthesized Music & Sound Effects โ
โ Procedural Audio โ Dynamic Background Music โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
```
### Project Structure
```
Motion-Shot/
โโโ App.tsx # Root component - Screen flow management
โโโ index.tsx # Application entry point
โโโ index.html # HTML template with MediaPipe CDN scripts
โโโ types.ts # TypeScript type definitions
โโโ vite.config.ts # Vite configuration
โโโ package.json # Dependencies & scripts
โ
โโโ components/
โ โโโ StoryPage.tsx # Cinematic story introduction
โ โ # - 5-chapter narrative
โ โ # - Particle effects
โ โ # - Animated transitions
โ โ
โ โโโ GameLauncher.tsx # Professional game menu
โ โ # - Tutorial/How to Play
โ โ # - Audio controls
โ โ # - Feature highlights
โ โ
โ โโโ GeminiSlingshot.tsx # Main game component (~1500 lines)
โ # - Game loop & rendering
โ # - Physics simulation
โ # - Hand tracking integration
โ # - Combo system
โ # - UI overlays
โ
โโโ services/
โ โโโ geminiService.ts # AI service layer
โ โ # - Gemini API integration
โ โ # - Strategic hint generation
โ โ # - Response parsing
โ โ
โ โโโ soundService.ts # Audio engine
โ # - Procedural music synthesis
โ # - UI sounds
โ # - Game sound effects
โ
โโโ docs/
โโโ GAME_DOCUMENTATION.md # This file
โโโ ARCHITECTURE.md # Technical architecture details
โโโ API_REFERENCE.md # Type definitions & functions
โโโ DEPLOYMENT.md # Hosting guide
โโโ CONTRIBUTING.md # Contribution guidelines
```
---
## 4. How It Works
### System Data Flow
```
โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโ
โ WEBCAM โโโโโถโ MediaPipe โโโโโถโ Game Loop โ
โ INPUT โ โ Hands SDK โ โ (60 FPS) โ
โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ
โผ โผ
โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ
โ Hand Position โ โ Canvas Render โ
โ Detection โ โ - Video BG โ
โ - 21 Landmarks โ โ - Bubble Grid โ
โ - Pinch Detect โ โ - Slingshot โ
โโโโโโโโโโโโโโโโโโโโ โ - Particles โ
โ โ - Ball Trail โ
โผ โโโโโโโโโโโโโโโโโโโโ
โโโโโโโโโโโโโโโโโโโโ โ
โ Slingshot โ โ
โ Mechanics โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ - Power Gauge โ โ
โ - Tension FX โ โโโโโโโโโโโโโโโโโโโโโโโค
โ - Release โ โ โ
โโโโโโโโโโโโโโโโโโโโ โ โ
โ โ โ
โผ โ โ
โโโโโโโโโโโโโโโโโโโโ โผ โ
โ Physics โ โโโโโโโโโโโโโโโโโโโโ โ
โ Simulation โ โ Screenshot โ โ
โ - Trajectory โ โ Capture โ โ
โ - Collision โ โ (480px JPEG) โ โ
โ - Ball Trail โ โโโโโโโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโ โ โ
โ โผ โ
โผ โโโโโโโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโ โ Gemini AI โ โ
โ Match Check โ โ Vision API โ โ
โ - Flood Fill โ โ - Analyze Grid โ โ
โ - Combo System โ โ - JSON Responseโ โ
โ - Score Update โ โโโโโโโโโโโโโโโโโโโโ โ
โ - Particles โ โ โ
โโโโโโโโโโโโโโโโโโโโ โ โ
โ โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโ
```
### Key Mechanics
#### 1. Hand Tracking & Pinch Detection
```
MediaPipe detects 21 hand landmarks. The game uses:
- Point 4: Thumb tip
- Point 8: Index finger tip
Pinch Distance = โ[(thumb.x - index.x)ยฒ + (thumb.y - index.y)ยฒ]
If Pinch Distance < 0.05 โ User is "grabbing" the ball
```
#### 2. Power Gauge System
```
Pull Distance determines shot power:
- 0-30%: Green (Weak shot)
- 30-60%: Yellow (Medium shot)
- 60-80%: Orange (Strong shot)
- 80-100%: Red (Maximum power)
Visual Feedback:
- Slingshot band changes color
- Tension rings pulse around ball
- Screen vibrates at high tension
- Power percentage displayed
```
#### 3. Combo System
```
Combos trigger when multiple matches occur within 3 seconds:
Combo Level โ Multiplier โ Visual Effect
โโโโโโโโโโโโโผโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโ
1x โ 1.0x โ Normal
2x โ 1.5x โ "COMBO x2!" text
3x โ 2.0x โ Screen glow
4x โ 2.5x โ Enhanced particles
5x+ โ 3.0x โ Screen shake + flash
```
#### 4. Bubble Matching (Flood Fill Algorithm)
```
When ball snaps to grid:
1. Find all connected same-color bubbles
2. Use hex-grid neighbor detection (6 neighbors)
3. If cluster >= 3 bubbles:
- Deactivate bubbles
- Create explosion particles
- Calculate score: (base ร combo ร bubble_count)
- Show floating score animation
```
### Scoring System
| Color | Points per Bubble | Strategic Value |
|-------|------------------|-----------------|
| ๐ด Red | 100 | Low - Common, easy targets |
| ๐ต Blue | 150 | Low-Medium |
| ๐ข Green | 200 | Medium |
| ๐ก Yellow | 250 | Medium-High |
| ๐ฃ Purple | 300 | High - Valuable targets |
| ๐ Orange | 500 | Highest - Rare, priority target |
**Combo Multipliers**: 1x โ 1.5x โ 2x โ 2.5x โ 3x (max)
---
## 5. How to Play
### Setup Requirements
- **Desktop computer** with webcam
- **Modern browser** (Chrome, Firefox, Edge)
- **Well-lit environment** for hand tracking
- **Node.js 18+** for development
### Installation
```bash
# 1. Clone and install
git clone https://github.com/Sengwamana/Motion-Shot.git
cd Motion-Shot
npm install
# 2. Configure API Key (for AI features)
# Create .env file with:
GEMINI_API_KEY=your_gemini_api_key_here
# 3. Start the game
npm run dev
# 4. Open http://localhost:3000
```
### Game Controls
```
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ GAME CONTROLS โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โ
โ 1. SHOW YOUR HAND ๐๏ธ โ
โ Position your hand in view of the webcam โ
โ โ
โ 2. PINCH TO GRAB ๐ค โ
โ Touch thumb to index finger near the slingshot ball โ
โ โ
โ 3. PULL BACK TO AIM ๐ฏ โ
โ While pinching, move hand backward to stretch slingshot โ
โ - Watch the power gauge (0-100%) โ
โ - Band color indicates power level โ
โ - Tension rings show charge intensity โ
โ โ
โ 4. RELEASE TO FIRE ๐ โ
โ Open your fingers to launch the ball โ
โ - Ball leaves glowing trail while flying โ
โ โ
โ 5. MATCH BUBBLES ๐ฅ โ
โ Hit 3+ same-colored bubbles to pop them โ
โ - Chain matches quickly for combo multipliers โ
โ โ
โ 6. FOLLOW AI HINTS ๐ง โ
โ Watch for Gemini's strategic recommendations โ
โ - Laser sight shows suggested target โ
โ โ
โ ALTERNATIVE: Mouse/Touch controls available as fallback โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
```
### Game Flow
```
โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ
โ STORY โโโโโถโ LAUNCHER โโโโโถโ GAME โ
โ PAGE โ โ MENU โ โ PLAY โ
โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ
โ โ โ
โ 5 Chapters โ How to Play โ Levels
โ Skip option โ Audio toggle โ Score
โ Navigation โ Start button โ Combos
โโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโ
```
---
## 6. Game Features
### Visual Effects
| Effect | Description |
|--------|-------------|
| **Ball Trail** | Glowing trail follows the ball during flight |
| **Tension Rings** | Pulsing circles around ball when pulling back |
| **Power Glow** | Ball glows brighter at higher power |
| **Floating Scores** | Animated score popups with combo multipliers |
| **Screen Shake** | Camera shake on big combos |
| **Particle Explosions** | Colorful particles when bubbles pop |
| **Release Flash** | Screen flash effect when firing |
### Audio System
| Sound Type | Trigger |
|------------|---------|
| **Background Music** | Procedural synthesized ambient music |
| **UI Click** | Button interactions |
| **Ball Launch** | Releasing the slingshot |
| **Bubble Pop** | Matching bubbles |
| **Combo Sound** | Achieving combo multipliers |
| **Game Start** | Starting the game |
| **Level Complete** | Clearing a level |
### AI Integration (Gemini)
The game integrates Google's Gemini AI for strategic assistance:
- **Board Analysis**: AI analyzes the current bubble configuration
- **Target Recommendation**: Suggests optimal bubble clusters to target
- **Color Selection**: Recommends which color ball to use
- **Strategic Rationale**: Explains why a particular move is beneficial
- **Laser Sight**: Visual indicator pointing to AI's recommended target
---
## 7. Technical Architecture
### State Management
| State Type | Usage | Purpose |
|------------|-------|---------|
| `useState` | UI elements | Score, hints, game state, level |
| `useRef` | Game physics | Ball position, velocity, bubbles (60fps) |
### Audio Engine
The sound service uses Web Audio API for procedural audio:
- **Oscillator-based synthesis** for all sounds
- **Chord progressions** for ambient music
- **Envelope generators** for dynamic volume
- **No audio files** - everything is synthesized in real-time
### Performance Optimizations
- **RequestAnimationFrame** for smooth 60fps rendering
- **Canvas layering** to minimize redraw
- **Substep collision detection** for fast-moving balls
- **Debounced AI calls** to prevent API spam
- **Image compression** for AI screenshots (480px JPEG 60%)
---
## Credits
**Motion Shot** - A game about the timeless connection between human hands and play.
- **Hand Tracking**: MediaPipe by Google
- **AI Strategy**: Google Gemini
- **Audio**: Web Audio API
- **Framework**: React + TypeScript + Vite
---
<div align="center">
*"The hand that once shaped history is now shaping the future of gaming."*
๐ฏ **Motion Shot** ๐ฏ
</div>
Installation Instructions
Quick Start
Prerequisites: Node.js 18+, Webcam, Desktop Browser
# Install dependencies
npm install
# Configure API key
cp .env.local.example .env.local
# Edit .env.local and add your GEMINI_API_KEY from https://aistudio.google.com/app/apikey
# Start the game
npm run dev
Open http://localhost:3000 in your browser and allow camera access.
๐ฎ How to Play
Show your hand to the webcam
Pinch near the slingshot ball
Pull back to aim and build power
Release to shoot!
Match 3+ bubbles of the same color to pop them. Watch the AI panel for strategic recommendations!
Prerequisites: Node.js 18+, Webcam, Desktop Browser
# Install dependencies
npm install
# Configure API key
cp .env.local.example .env.local
# Edit .env.local and add your GEMINI_API_KEY from https://aistudio.google.com/app/apikey
# Start the game
npm run dev
Open http://localhost:3000 in your browser and allow camera access.
๐ฎ How to Play
Show your hand to the webcam
Pinch near the slingshot ball
Pull back to aim and build power
Release to shoot!
Match 3+ bubbles of the same color to pop them. Watch the AI panel for strategic recommendations!