A classic Snake Game developed with Python and Pygame. This project includes basic game mechanics, keyboard control, score tracking, game over detection, restart function, and a custom icon image integrated into the game interface.
-
🐍 Classic Snake gameplay
-
⌨️ Keyboard controls:
- Arrow Keys (
↑ ↓ ← →) - WASD keys (
W A S D)
- Arrow Keys (
-
🍎 Food generation system
-
📊 Real-time score display
-
💀 Game Over screen
-
🔄 Press
Rto restart the game -
🚪 Press
ESCto exit -
🖼️ Custom image/icon support
- Python 3
- Pygame Library
Snake-Game/
│
├── snake.py # Main game program
├── jim.png # Custom game icon/image
└── README.md # Project documentation
Make sure Python 3 is installed:
python3 --versionOpen the terminal in this project folder and run:
python3 -m pip install pygameStart the game using:
python3 snake.pyThe game window will open automatically.
| Key | Action |
|---|---|
| ↑ | Move Up |
| ↓ | Move Down |
| ← | Move Left |
| → | Move Right |
| W | Move Up |
| S | Move Down |
| A | Move Left |
| D | Move Right |
| R | Restart Game |
| ESC | Quit Game |
You can replace the image file:
jim.png
with your own image.
Make sure the new image is placed in the same folder as:
snake.py
and update the filename in the Python code if necessary.
Example:
Through this project, I practiced:
- Python programming fundamentals
- Object-oriented programming concepts
- Game loop design
- Event handling
- Collision detection
- Image loading and rendering with Pygame
Created by Yiming Guan
A simple project exploring Python programming and game development.
