A gesture-controlled retro arcade game collection powered by MediaPipe hand tracking and machine learning. Control classic games like Pac-Man, Brick Breaker, and Space Invaders using hand gestures captured through your webcam.
- Real-time hand tracking using MediaPipe's hand landmark detection
- Gesture recognition powered by a trained Random Forest classifier
- Three classic arcade games with retro CRT visual effects
- Dual control support - play with gestures or keyboard
- Leaderboard system to track high scores
| Game | Description | Controls |
|---|---|---|
| Pac-Man Maze | Navigate the maze, collect pellets, avoid ghosts | UP/DOWN/LEFT/RIGHT gestures |
| Brick Breaker | Break bricks with bouncing balls, collect power-ups | LEFT/RIGHT gestures |
| Space Invaders | Defend Earth from descending alien forces | LEFT/RIGHT to move, gesture 4 to shoot |
- Python 3.10 or higher
- Webcam
- Linux/macOS/Windows
-
Clone the repository
git clone https://github.com/krAsync/hand-controlled-retro-games.git cd hand-controlled-space-invaders -
Create a virtual environment
python -m venv .venv source .venv/bin/activate # Linux/macOS # or .venv\Scripts\activate # Windows
-
Install dependencies
pip install -r requirements.txt
python retro.pyThis launches a fullscreen menu where you can select from three games.
Menu Navigation:
1,2,3- Select game directlyUP/DOWNarrows +ENTER- Navigate and selectQorESC- Quit
In-Game:
ESC- Return to menu- Hand gestures control movement/actions (displayed on screen)
| Gesture | Action |
|---|---|
| Gesture 1 | UP |
| Gesture 2 | LEFT |
| Gesture 3 | DOWN |
| Gesture 4 | RIGHT / SHOOT |
hand-controlled-space-invaders/
├── retro.py # Main game application
├── leaderboard.json # High scores
├── src/
│ └── MediPipeHandsModule/
│ ├── HandTrackingModule.py # Hand detection & landmarks
│ ├── GestureEvaluator.py # Gesture classification
│ └── GestureEvaluatorCNN.py # Alternative CNN classifier
├── scripts/
│ ├── capture.py # Record gesture training data
│ ├── train.py # Train Random Forest model
│ ├── train_cnn.py # Train CNN model
│ └── eval.py # Evaluate model live
├── models/
│ ├── hand_landmarker.task # MediaPipe hand model
│ └── gesture_model.pkl # Trained gesture classifier
├── data/
│ └── retro/
│ └── gestures.csv # Gesture training data
└── assets/ # Game sprites
python scripts/capture.pyPress number keys (0-9) while showing the corresponding gesture to your webcam. The script records hand landmarks to data/retro/gestures.csv.
python scripts/train.pyThis trains a Random Forest classifier and saves it to models/gesture_model.pkl.
python scripts/eval.pyTest your trained model in real-time with webcam feedback.
- Detection: MediaPipe extracts 21 hand landmarks per frame
- Normalization: Landmarks are normalized relative to wrist position and bounding box
- Classification: 42 landmark features + handedness fed to Random Forest classifier
- Stabilization: 5-frame majority voting reduces false positives
- Pygame-CE for rendering and input handling
- Delta-time scaling for frame-rate independent movement
- Retro effects: Scanlines, colored borders, shadow text
| Package | Version | Purpose |
|---|---|---|
| mediapipe | 0.10.33 | Hand landmark detection |
| opencv-python | 4.13.0 | Video capture & processing |
| pygame-ce | 2.5.7 | Game rendering |
| scikit-learn | 1.8.0 | Gesture classification |
| numpy | 2.4.4 | Numerical operations |
| joblib | 1.5.3 | Model serialization |
This project is open source and available under the MIT License.