Skip to content

mathisdelsart/ModernSnake

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Snake Game 🐍

Python Pygame

A modern, visually enhanced implementation of the classic Snake game in Python using Pygame.
Experience smooth gameplay, modern graphics, and nostalgic fun!

AboutFeaturesInstallationControlsProject StructureCustomization


About

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

Core Gameplay

Score = Snake Length - 3 (snake starts with 3 segments)
Goal: Eat apples → Grow longer → Avoid self-collision → Beat high score!

Features

Game Features

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)

Installation

Prerequisites

  • Python 3.7 or higher
  • Pygame library

Setup

# Clone the repository
git clone https://github.com/mathisdelsart/ModernSnake.git
cd ModernSnake

# Install dependencies
pip install pygame

# Run the game
python main.py

Controls

Key Action
SPACE Start game / Restart after game over
Move Up
Move Down
Move Left
Move Right
ESC Quit game

How to Play

  1. Press SPACE to start the game
  2. Use arrow keys to control the snake's direction
  3. Eat red apples to grow longer and increase your score
  4. Avoid colliding with your own body and the walls
  5. Try to beat your best score!

Project Structure

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

Customization

You can easily customize the game by modifying src/Configs.py:

Grid Size & Difficulty

# 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

Visual Settings

# 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

Color Schemes

# 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)

Game Difficulty

The game speed is automatically calculated based on grid size - no manual adjustment needed! Larger grids automatically run faster to maintain challenge.

Future Enhancements

Want to take this project further? Consider adding:

  • Sound Effects: Add audio for eating apples, game over, etc.

  • Custom Fonts: Replace system fonts with stylish TTF fonts

  • Power-ups: Special apples with temporary effects (speed boost, invincibility, etc.)

Game Rules

  1. The snake starts with length 3 and moves continuously
  2. Eating an apple increases the snake's length by 1 and adds 1 to the score
  3. Touching the walls ends the game (no teleportation!)
  4. Colliding with yourself (when length ≥ 5) ends the game
  5. Your best score is automatically saved
  6. Game speed automatically adapts to grid size

Author

Mathis DELSART

Classic arcade fun with modern polish — How long can you grow? 🐍🍎

About

ModernSnake — a modern, polished implementation of the classic Snake game. Smooth gameplay, clean visuals, and a refined user experience.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages