A gesture-controlled arcade game written in Python using OpenCV and PyGame. I made this to experiment with computer vision and to learn OpenCV in a fun way. The main idea is that the player is able to make hand-gestures to control a spaceship and defeat enemies. The three hand-gesture inputs are:
- Moving the spaceship around (simply move your hand around horizontally)
- Shooting a bullet (point with index finger)
- Flipping over the ship to target enemies on the other side (raise your thumb and pinkie finger)
On the left side of the window is the UI, which displays a video feed taken from your computer's camera. There are indicators for which hand gesture the player is currently making (overlayed on top of and above the video feed). It also contains information such as points and health. On the right side of the window is the actual game, which is essentially space invaders except the ship can flip around and shoot in two directions. There is only one level.
Gesture-Controlled.Arcade.Game.OpenCV.x.PyGame.mp4
Turn on sound!
The instructions below assume a Unix-like environment.
-
If you don't have Python3 already installed on your system, install it from https://www.python.org/downloads/. Ensure you have the latest version of pip installed by following the instructions on https://pip.pypa.io/en/latest/installation/#ensurepip.
-
Clone the repository
git clone https://github.com/omarkhan03/cv-game.git
-
CD into the Code directory
cd Code
-
Install all requirements
pip install -r requirements.txt
-
Run main.py
python3 main.py
Note - you may need to click on a prompt to allow the terminal to access your computer's camera.
-
Thanks to Murtaza's workshop's videos for helping to learn OpenCV as well as the CvZone library, from which I used the hand tracking module.
-
I built off of this PyGame tutorial by Clear Code on YouTube. Thanks a lot!