This is a fork of the original Flappy Bird-style game implemented with Python. In this fork, the game is controlled using facial gestures captured by a webcam. The project uses Pygame for graphics, OpenCV for webcam access, and MediaPipe for face mesh detection.
- Face-Controlled Gameplay: Control the bird's vertical movement using facial gestures. The bird's position adjusts based on the vertical position of your nose tip.
- Dynamic Obstacles: Pipes spawn at varying intervals and positions, increasing the difficulty as you progress.
- Real-Time Updates: The game updates the screen in real-time with the webcam feed and game elements.
This repository is a fork of the original FlappyBirdCV repository. The primary modifications include:
- Integration of face-controlled input using MediaPipe.
- Adjustments to game mechanics to accommodate face detection.
- Python 3.x
- Pygame
- OpenCV
- MediaPipe
- NumPy (for array operations)
You can install the required Python libraries using pip:
pip install -r requirements.txt
-
Clone the Repository:
git clone https://github.com/rishibharadwajsai/FlappyBird-OpenCV.git cd FlappyBird-OpenCV
-
Download Assets: Ensure you have the required image assets (
bird_sprite.png
andpipe_sprite_single.png
). Place these image files in the same directory as your script. -
Run the Game:
python main.py
-
Initialization:
- The game initializes the webcam feed using OpenCV and sets up the game window with Pygame.
- It loads the bird and pipe images, sets up initial parameters, and starts the game loop.
-
Face Detection:
- The game uses MediaPipe's Face Mesh model to detect facial landmarks. Specifically, the y-coordinate of the nose tip is used to control the bird's vertical position.
-
Game Loop:
- Input Handling: The game checks for user input (e.g., quitting the game).
- Frame Processing: Captures the current frame from the webcam, processes it for face landmarks, and adjusts the bird's position.
- Pipe Management: Pipes are moved across the screen, and new pipes are spawned periodically.
- Collision Detection: Checks if the bird collides with any pipes, which ends the game if true.
- Score Tracking: Updates and displays the score based on the bird passing through the pipes.
-
Difficulty Progression:
- The game increases in difficulty over time by reducing the interval between pipe spawns.
- Bird and Pipe Images: Replace
bird_sprite.png
andpipe_sprite_single.png
with your own images to customize the look of the game. - Difficulty Settings: Adjust parameters such as
time_between_pipe_spawn
andspace_between_pipes
to modify the game's difficulty.
- Empty Frame: If the webcam feed is empty, ensure the webcam is connected and working properly.
- Missing Assets: Ensure that the image files (
bird_sprite.png
andpipe_sprite_single.png
) are in the correct directory.
This project is licensed under the GPL-3.0 License. See the LICENSE file for details.