In this project I am going to learn how to use Gesture Control to create Snake Game. I first look into hand tracking and then I will use the hand landmarks to find gesture of my hand to move the Snake.
- Clone this repository on your computer
https://github.com/paveldat/snake_game.git
- Install all the requirements
run libraries.bat
- Run the program
python main.py
You might face issue with webcam not showing and you get errors.
To solve it just change the value in this line (for example to 1
).
cap = cv2.VideoCapture(0)
Increment this number until you see your webcam.
Move your index finger across the screen, guiding the snake with your finger. Donuts appear in random places, which you need to collect to increase the length of the snake's body, as well as increase your score.
If you lose, press the "r" on your keyboard and start moving the snake further. Thus, the game will start over.
Compute distance between head and each point. If any low below a threshold collision detected, then Game Over.