A classic Snake game implementation that runs in your terminal using Python's curses library.
- Smooth gameplay with adjustable speed that increases as you score
- Multiple control schemes: WASD keys or arrow keys
- Real-time scoring with display
- Pause/resume functionality
- Game over detection with restart option
- Collision detection for walls and self-collision
- Responsive terminal UI with borders and status messages
- Food generation that avoids snake body
- Color-coded elements (green snake, red food, yellow score)
- Python 3.6 or higher
- Terminal with at least 30x10 character size
- Unix-like system (Linux, macOS) or Windows with proper curses support
- Clone or download this repository
- No additional dependencies needed - uses Python's built-in
curseslibrary
-
Run the game:
python3 snake_game.py
-
Controls:
- Movement: Use WASD keys or arrow keys to control the snake
- Pause/Resume: Press
Spaceto pause or resume the game - Restart: Press
Rwhen game is over to restart - Quit: Press
Qto quit the game
-
Objective:
- Control the snake (@) to eat food (*)
- Each food eaten increases your score by 10 points
- The snake grows longer with each food eaten
- The game speeds up slightly as your score increases
- Avoid hitting the walls or the snake's own body
@- Snake heado- Snake body*- Food#- Border walls- Score is displayed at the top
- Game status (PAUSED, GAME OVER) shown when applicable
- Plan your moves ahead - the snake can't reverse direction
- Use the pause feature (
Space) to take a break and plan your strategy - The game gets faster as you score more points, so stay focused!
- Try to avoid trapping yourself in corners
- Built with Python's
curseslibrary for terminal graphics - Non-blocking input for smooth real-time gameplay
- Collision detection for walls and self-collision
- Dynamic food generation that avoids snake body
- Color support for enhanced visual experience
- Responsive to terminal resizing (minimum 30x10 required)
- "Terminal too small" error: Resize your terminal to at least 30 characters wide and 10 lines tall
- Colors not showing: Your terminal may not support colors - the game will still work in monochrome
- Controls not responsive: Make sure your terminal has focus and try different keys (WASD vs arrows)
This project is open source and available under the MIT License.
Enjoy playing Snake in your terminal! 🎮