A modern, visually enhanced implementation of the classic Snake game in Python using Pygame.
Experience smooth gameplay, modern graphics, and nostalgic fun!
About • Features • Installation • Controls • Project Structure • Customization
This project is a fully-featured implementation of the classic Snake game built with Python and Pygame. It features modern visual enhancements including:
- Gradient color effects on the snake body
- Smooth rounded corners and borders
- 3D-styled apple with shadow effects
- Animated snake with directional eyes
- Background grid for better spatial awareness
- Polished UI with score display panels
Score = Snake Length - 3 (snake starts with 3 segments)
Goal: Eat apples → Grow longer → Avoid self-collision → Beat high score!
| Feature | Description |
|---|---|
| Modern Graphics | Gradient snake body, 3D apple with leaf, rounded corners |
| Visual Effects | Background grid, realistic snake eyes, shadow effects |
| Score System | Persistent best score tracking in dedicated top bar |
| Dynamic Difficulty | Speed auto-adjusts based on grid size |
| Wall Collision | Touch the walls = Game Over |
| Configurable Grid | Customize grid size (columns x rows) |
- Python 3.7 or higher
- Pygame library
# Clone the repository
git clone https://github.com/mathisdelsart/ModernSnake.git
cd ModernSnake
# Install dependencies
pip install pygame
# Run the game
python main.py| Key | Action |
|---|---|
| SPACE | Start game / Restart after game over |
| ↑ | Move Up |
| ↓ | Move Down |
| ← | Move Left |
| → | Move Right |
| ESC | Quit game |
- Press SPACE to start the game
- Use arrow keys to control the snake's direction
- Eat red apples to grow longer and increase your score
- Avoid colliding with your own body and the walls
- Try to beat your best score!
Snake/
├── main.py # Entry point - initializes game components
├── BestScore.txt # Persistent high score storage
├── README.md # This file
├── .gitignore # Ignore some files for Github
├── image/ # Screenshots
└── src/
├── Configs.py # Game constants, colors, visual settings
├── Game.py # Main game loop, menu, event handling
├── Snake.py # Snake class - movement, collision, rendering
├── Apple.py # Apple class - spawning, rendering
└── Score.py # Score management and display
You can easily customize the game by modifying src/Configs.py:
# Customize the grid size (affects game area and difficulty)
GRID_COLS = 30 # Number of columns (width in squares)
GRID_ROWS = 20 # Number of rows (height in squares)
# The game speed is automatically calculated:
# - Smaller grids (e.g., 15x10) = slower, easier
# - Default (30x20) = medium difficulty
# - Larger grids (e.g., 40x30) = faster, harder# Screen size is calculated automatically based on grid
SQUARE = 30 # Size of each grid cell
BORDER_RADIUS = 5 # Roundness of corners
GRID_ENABLED = True # Toggle background grid
SCORE_BAR_HEIGHT = 100 # Height of score bar at top# Snake colors
SNAKE_HEAD = (50, 205, 50)
SNAKE_BODY = (34, 139, 34)
SNAKE_TAIL = (0, 100, 0)
# Apple colors
APPLE_RED = (220, 20, 60)
APPLE_HIGHLIGHT = (255, 99, 71)
# UI colors
ACCENT_COLOR = (0, 191, 255)
SCORE_COLOR = (255, 215, 0)The game speed is automatically calculated based on grid size - no manual adjustment needed! Larger grids automatically run faster to maintain challenge.
Want to take this project further? Consider adding:
-
Sound Effects: Add audio for eating apples, game over, etc.
- Find free sounds on Freesound or OpenGameArt
-
Custom Fonts: Replace system fonts with stylish TTF fonts
- Download from Google Fonts or DaFont
-
Power-ups: Special apples with temporary effects (speed boost, invincibility, etc.)
- The snake starts with length 3 and moves continuously
- Eating an apple increases the snake's length by 1 and adds 1 to the score
- Touching the walls ends the game (no teleportation!)
- Colliding with yourself (when length ≥ 5) ends the game
- Your best score is automatically saved
- Game speed automatically adapts to grid size
Classic arcade fun with modern polish — How long can you grow? 🐍🍎

