This Snake Game is a classic arcade-style game built using Python and the Turtle graphics module. The game allows the player to control a snake and navigate it on the screen to eat food and grow in length. The goal is to achieve the highest possible score without colliding with the walls or the snake's own body.
- Snake body: The game starts with a snake consisting of three squares, forming the snake's initial length.
- Snake motion: The snake moves continuously forward on the screen.
- Motion control: The player can control the snake's direction using the keyboard arrow keys.
- Food generation: Food is randomly generated on the screen for the snake to eat.
- Score tracking: The score is updated every time the snake eats food.
- HighScore retention: The highest score earned by the user can now be updated and rembered antime you play the game.
- Collision detection: The game detects collisions with the walls and the snake's own body, leading to game over.
- Game restart: The player can restart the game by pressing the spacebar when prompted.
- Make sure you have Python installed on your system (Python 3.6 or higher).
- Clone or download the project files from the repository: [Link to repository]
- Open a terminal or command prompt and navigate to the project directory.
- Run the following command to install the required dependencies:
pip install turtle
- Run the game by executing the
main.pyfile. - Follow the on-screen instructions and use the arrow keys to control the snake.
- Up Arrow: Move the snake upwards.
- Down Arrow: Move the snake downwards.
- Left Arrow: Move the snake to the left.
- Right Arrow: Move the snake to the right.
The project consists of the following classes:
main.py: The main file that initializes the game and handles the game loop.snake.py: Defines theSnakeclass responsible for creating and controlling the snake's behavior.food.py: Defines theFoodclass responsible for generating and updating the food on the screen.scoreboard.py: Defines theScoreBoardclass responsible for tracking and displaying the player's score.notes.py: Contains additional code snippets showcasing the concept of class inheritance.border.py: Contains code to define the boarders of the screen if the user eventually decides to go fullscreen.
Contributions to this project are welcome. If you find any issues or want to add new features, please create a new issue in the project repository and submit a pull request.
This project is licensed under the MIT License.
Special thanks to Angla Yu for bringing about the idea for this project through her 100 days of code course on Udemy
