A simple Snake Game implemented in Python using the Turtle graphics library. The game features a snake that grows longer as it consumes food, and the objective is to maximize the score without colliding with the game boundaries or the snake's own body.
-
Clone or download the repository to your local machine:
git clone https://github.com/your_username/your_repository.git
-
Ensure you have Python and the required libraries installed. You can install the necessary libraries using:
pip install pygame
-
Run the game by executing the Python script:
python snake_game.py
- Use the arrow keys (Up, Down, Left, Right) to control the snake's direction.
- The snake starts with a single segment.
- Eating food increases the snake's length and score.
- The game ends if the snake collides with the game boundaries.
- The game also ends if the snake collides with its own body.
You can customize certain aspects of the game by modifying the constants defined at the beginning of the script:
SCREEN_WIDTH
andSCREEN_HEIGHT
define the dimensions of the game window.SNAKE_SIZE
andFOOD_SIZE
determine the size of the snake segments and food items.- Color constants (
BLACK
,WHITE
,RED
,GREEN
,BLUE
) can be adjusted to change the appearance of the game elements.
Feel free to explore and modify the code to add new features or enhance existing ones.
- Python 3.x
- Pygame library
This game is inspired by classic Snake games and was created for educational purposes. It serves as a simple example of game development using Python.
This Snake Game is licensed under the MIT License. Feel free to use, modify, and distribute the code for your projects.# basicSnakeGame