This is a basic version of snake game. As it moves forward, it leaves a trail behind, resembling a moving snake. The player loses when the snake runs into the screen border (there are four walls around the screen) or itself. Snake has 5 lives. A sole player attempts to eat apples by running into them. Each apple eaten makes the snake longer and adds points. Big apples give more points.
As you run a program first the popup window shows up asking to enter the name of the player. By the end of the game the results (player's name, apples amount, points) are written to the .txt file.
The control keys are:
- "up"
- "down"
- "left"
- "right".
Double press makes the snake to speed up.
Used libraries:
- pygame
- kivy
Pre-requirements:
- python 3.9 >
- virtualenv
Install virtualenv
pip install virtualenvOn Windows OS you need to add virtualenv installation path into PATH environment variable of the system. Example tutorial on that
Create virtual environment. From the root directory run.
virtualenv snakegameenvwhere "snakegameenv" is the custom name of the environment
Activate the environment
On Windows you need this command:
<environment name>\Scripts\activatein our case:
snakegameenv\Scripts\activateOn Unix system
source snakegameenv/bin/activateInstall requirements
pip install -r requirements.txtCreate and activate environment:
conda create --name Snake-Pygame python=3.10
conda activate Snake-PygameInstall packages:
conda install --file requirements.txtSave all installed packages to the list of requirements:
With pip
pip freeze > requirements.txtWith conda
conda list --export > requirements.txtIn the terminal run
python ./src/main.pyIn PyCharm with Run button in the top menu
