Table of Contents
This project is an implementation of the traditional snake game, written in Python 3.12 and utilizing the turtle graphical library.
- Getting Python:
- Check if Python is installed by running the following commands in your terminal (for macOS/Linux) or command prompt/PowerShell (for Windows):
python --version
- If Python is not installed or the version is older than 3.12, you can install it from here.
- Check if Python is installed by running the following commands in your terminal (for macOS/Linux) or command prompt/PowerShell (for Windows):
Getting Git:
- Git is required to clone this repository. If you don't have Git installed, download it here.
-
Clone the Repository:
- Choose the folder on your computer where you want to save the project.
- Open the terminal window/command prompt in that location.
- Clone the project using the following command:
git clone https://github.com/VojtaMi/Snake_game
-
Run the Game using Python:
- In the same terminal window, run the following command:
python Snake_game/main.py
- In the same terminal window, run the following command:
Upon opening the project, a simple menu is displayed.
- w: Select upper option
- s: Select lower option
- Enter: Confirm the selected option
- Play Game: Start a new snake game
- Leaderboard: Display the table of the highest saved scores
- Exit: Terminate the program
The goal is to eat as many green dots as possible. After eating a dot, the snake's body grows, and the player's score increases. The score table is shown at the bottom-right corner.
- w: Move up
- a: Move left
- s: Move down
- d: Move right
The game ends when the snake hits the border, collides with its body, or covers the entire play field.
If the score qualifies for the leaderboard, a prompt for the player's name is displayed. (The player's name is limited to 10 characters for the leaderboard table. When no name is entered, "___" is used.)
The leaderboard stores the highest scores, with a maximum of 5 entries.
A score qualifies for the leaderboard if the table has less than 5 members or if the score is higher than the last member's score.
The leaderboard display menu has only one option: Exit, which returns the user to the main menu when Enter is pressed.
This project follows object-oriented principles, making some functionalities easily reusable in other programs. Notably, the Menu class from the menu.py module and the InputHandler class from utils.py can be useful in other projects.
The program generates a file named high_scores.csv in the project's folder to permanently save the leaderboard, ensuring persistence even after the program terminates.
For detailed documentation, please refer to the docstrings and code comments throughout the project.
Distributed under the MIT License. See LICENSE.txt
for more information.