A computer vision-powered Snake game built with Python, OpenCV, and MediaPipe. Instead of using your keyboard, you control the snake's direction in real-time by moving your index finger in front of your webcam.
- Gesture Control: Intuitive hand-tracking to guide the snake.
- Scoring System: Real-time score tracking and persistent High Score for the session.
- Visual Feedback: Red hand-landmark overlays to show what the AI is tracking.
- Responsive Gameplay: Optimized for 8 FPS to balance control and difficulty.
| Library | Purpose |
|---|---|
| MediaPipe | AI Hand Landmark detection (Tracking index finger). |
| Pygame | Game engine for rendering the snake, food, and UI. |
| OpenCV | Capturing and processing the webcam video stream. |
| NumPy | Managing coordinate arrays for the snake body. |
- Clone the repository:
git clone [https://github.com/Jemelimercy/Hand-Controlled-Snake-.git](https://github.com/Jemelimercy/Hand-Controlled-Snake-.git) cd Hand-Controlled-Snake- Set up a Virtual Environment (Optional but Recommended): python -m venv venv
.\venv\Scripts\activate
source venv/bin/activate
Install Dependencies:
pip install opencv-python mediapipe pygame numpy
Run the Game: python snake_game.py
๐ฎ How to Play Calibration: Ensure your hand is visible to the webcam. You will see red dots on your knuckles.
Movement: Move your Index Finger Tip (Landmark 8) to steer.
Move finger Up/Down/Left/Right relative to the snake's head to change direction.
Objective: Eat the red food squares to grow and increase your score.
Game Over: Hitting the wall or your own tail will reset your score (but your High Score remains!).
Quit: Press 'Q' or close the window to exit.
๐ Acknowledgments Inspired by the classic Dino and Snake games.
Powered by Google's MediaPipe Hand Tracking.