markdown
A classic Snake game implemented in Python using the Pygame library with enhanced visual features.
In this game, you control a snake that moves around a grid, eating food to grow longer. The objective is to achieve the highest score possible without crashing into the walls or the snake's own body.
- Intuitive controls using arrow keys
- Score tracking displayed in a stylish header
- Game over screen with restart option
- Enhanced visuals:
- Grid background for better spatial awareness
- Snake with expressive eyes on its head
- Circular red food instead of a square
- Semi-transparent overlay on game over
- Bordered game area and score header
- Python 3.x
- Pygame library
Install Pygame using pip:
pip install pygame
Ensure Python and Pygame are installed on your system.
Save the game code in a file, e.g., snake_game.py.
Run the game using Python:
python snake.py
Arrow Keys: Move the snake up, down, left, or right
R: Restart the game after "Game Over"
The snake starts with a length of 3 segments and moves automatically.
Eat the red circular food to grow longer and increase your score.
Avoid hitting the walls or the snake's own body to keep playing.
When the game ends, press 'R' to start over.
Enjoy the game!