This project is a simple implementation of the classic Snake Game using Python and the Pygame library.
Make sure you have Python and Pygame installed on your machine.
Install Pygame using the following command:
pip install pygame
Versions used when developing:
- Python 3.10
- pygame==2.5.2
Run the script in your terminal or preferred Python environment using:
python snake_game.py
Use the arrow keys to control the snake (Up, Down, Left, Right). Eat the red apples to grow the snake and increase your score. Avoid collisions with the window borders and the snake's own body. If the game is over, press Enter to restart.
- ↑ (Up arrow): Change snake direction to up.
- ↓ (Down arrow): Change snake direction to down.
- ← (Left arrow): Change snake direction to left.
- → (Right arrow): Change snake direction to right.
The snake grows longer each time it eats an apple. The game ends if the snake collides with the borders or itself. The score is displayed at the top of the game window.
You can customize the game by modifying the following parameters in the script:
FPS: Set the frames per second for the game.
WIDTH and HEIGHT: Adjust the dimensions of the game window.
Colors: Modify the color values for WHITE, BLACK, GREY, GREEN, and RED to change the appearance of the game elements.
Feel free to explore and enhance the game according to your preferences!
Enjoy playing the Snake Game! 🐍🍎