A fun and interactive ping pong game controlled by hand gestures using a webcam. This project combines the power of MediaPipe, OpenCV, and Pygame to create a real-time, gesture-based gaming experience.
- Real-Time Hand Tracking: Uses MediaPipe to detect hand gestures.
- Interactive Gameplay: Control paddles with your hand movements via webcam.
- Dynamic Background: Webcam feed displayed as the game background.
- Score Tracking: Keep track of your score as you play.
- Game Over Screen: Displays final score with a restart option.
Ensure you have the following installed:
- Python 3.7 or above
- OpenCV (
cv2
) - Pygame
- MediaPipe
- Install Dependecies:
pip install pygame opencv-python mediapipe ##Note: If you encounter missing dependencies, install them using the following command: pip install pygame opencv-python mediapipe --break-system-packages
- Clone the repository:
git clone https://github.com/krish-gupta21/Ping-Pong-Gesture-Controlled cd Ping-Pong-Gesture-Controlled
- Give file permisions:
chmod +x pingpong.py
- Run the file:
python pingpong.py
- Start the Game:
- Run the script using the command:
python pingpong.py
.
- Run the script using the command:
- Control the Paddles:
- Move your left hand to control the left paddle.
- Move your right hand to control the right paddle.
- Objective:
- Prevent the ball from going out of bounds by hitting it with the paddles.
- Scoring:
- Earn points every time the ball hits a paddle.
- Game Over:
- The game ends if the ball goes out of bounds. Click restart button to restart the game.
Play in a well-lit environment for better hand detection accuracy.