Simple snake game with pygame
Run command to install dependencies:
pip3 install -r /path/of/game/requirements.txt After you have installed the dependencies start the game with
python3 /path/to/game/main.pyAfter you started it wait for both the game and gesture recognition to start, then you can play the game.
You can control the game either with the arrow keys or with the corresponding gestures.
The goal is to reach a good score.
You can gather points by eating the purple food on the field.
The game ends if you eat yourself. (run into yourself...classical snake game)
Set the snake's direction to right.
Set snake's direction to left.
Set snake's direction upwards
Set snake's direction downwards
I know... the implementation of the program is terrible.
The original plan was to start in two different processes the gesture detection and the game and give them a shared object so they can communicate with each other. But the problem with this idea is that the pygame.Surface object is unpickleable which is a problem because if a process is made with the multiprocessing module, the process's object needs to be pickled to make the processes be able to communicate with each other (brief explanation...I do not want to go into the details) so I started the gesture recognition processe inside th Game class which is a terrible practice but the only way to make this thing work (or as it seems, and I do not want to deal with the lowest-level stuff like forking/spawning processes and configuring them, because it would make even harder to deal with the shared data).