A classic Snake game implementation using Python and Pygame with Q as the pair programmer.
- Classic Snake gameplay mechanics
- Arrow key controls
- Score tracking
- Pause functionality
- Game over and restart system
- Clean, simple graphics
- 800x600 window size (browser-friendly)
- Python 3.11 or higher
- Pygame 2.0.0 or higher
- Clone or download the game files
- Install the required dependencies:
pip install -r requirements.txt
-
Run the game:
python snake_game.py
-
Use the arrow keys to control the snake:
- ↑ UP: Move up
- ↓ DOWN: Move down
- ← LEFT: Move left
- → RIGHT: Move right
-
Game Controls:
- P: Pause/Resume game
- ESC: Quit game
- SPACE or ENTER: Restart after game over
- Guide the snake to eat the red food
- Each food eaten increases your score by 10 points
- The snake grows longer with each food consumed
- Avoid hitting the walls or the snake's own body
- The game ends when the snake collides with walls or itself
- Smooth Movement: Consistent frame rate for smooth gameplay
- Collision Detection: Accurate wall and self-collision detection
- Score System: Points awarded for each food consumed
- Pause Function: Pause and resume gameplay anytime
- Restart Option: Quick restart after game over
- Visual Feedback: Clear distinction between snake head, body, and food
- Window Size: 800x600 pixels
- Grid System: 20x20 pixel cells
- Frame Rate: 10 FPS for classic Snake feel
- Snake starts with 3 segments in the center
- Food spawns randomly, avoiding snake body
If you encounter any issues:
- Make sure Python 3.11+ is installed
- Verify Pygame is properly installed:
pip list | grep pygame
- Try reinstalling Pygame:
pip uninstall pygame && pip install pygame
Key | Action |
---|---|
Arrow Keys | Move snake |
P | Pause/Resume |
ESC | Quit game |
SPACE/ENTER | Restart (after game over) |
Enjoy playing Snake!