Turtle Snake Game
A classic Snake game implemented in Python using the
turtle module. The game features configurable window size and speed, grid‐aligned food, score tracking, and self‐collision/border detection.Table of Contents
Features
Smooth, grid‐based movement
Configurable frame‐rate (speed) and window size
Randomly placed food aligned to grid
Scoreboard with point tracking
Border and self‐collision detection (Game Over)
Modular design (separate
Snake class, game controller, utils, and config)Requirements
Python 3.7+
Standard library only (
turtle, argparse, random, time)Installation
Clone this repository:
(Optional) Create and activate a virtual environment:
Usage
Run the game via the provided
main.py script. You can customize the window size and movement speed:--width : Window width in pixels (default 600)--height: Window height in pixels (default 600)--speed : Movement delay in milliseconds (default 16 for ~60 FPS)Example, to run at 800×800 pixels and a bit slower (~30 FPS):
Game Controls
Arrow keys: Change snake direction (
Up, Down, Left, Right)Close window: Ends game immediately (also triggers Game Over on collision)
Configuration
All game constants live in
config.py:Feel free to tweak these to change look & feel.
Project Structure
Development
Edit configuration in
config.py for custom behavior.Extend or modify
Snake class (in snake.py) for new features (e.g. power‐ups).Add new game modes or UIs in
snake_game.py.Run
python main.py after changes to test.License
This project is released under the MIT License. Feel free to fork and customize!
0 likes · 18 views · Jul 17, 2025
A classic Snake game implemented in Python using the `turtle` module with configurable window size, speed, grid‐aligned food, and score tracking.