Skip to content

TenathDilusha/Snake-Game

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🐍 Classic Snake Game (Python)

A fun and classic Snake Game built using Python’s turtle module. The project is structured with multiple Python files for clarity, modularity, and easy expansion.

🎮 How the Game Works

Use the arrow keys to control the snake. Eat the food to grow longer. Each food increases your score. The high score is saved in data.txt and automatically loaded when the game starts. After losing, press SPACE to restart the game instantly.

❌ The game ends if:

The snake hits the wall. The snake collides with its own body.

🚀 Features

Smooth snake movement Randomly spawning food Scoreboard with persistent high score (stored in data.txt) Press Space to restart without quitting Clean object-oriented class design Game over screen

Simple, lightweight, no external dependencies

▶️ How to Run the Game

Make sure you have Python 3 installed. Keep all files in the same folder: main.py snake.py food.py scoreboard.py data.txt

Run the game with:

python main.py

🔧 Requirements

No extra installations needed. Uses only Python's built-in:

turtle random

📝 About the Code

This project demonstrates:

Object-oriented programming (OOP) Game loop logic with while loops and screen updates Collision detection Saving/loading high scores using file handling (data.txt) Clean class-based architecture for Snake, Food, and Scoreboard

📜 License

This project is free to use, modify, and expand. Have fun coding — and enjoy the game! 🐍🔥

About

This is the classic Snake game made with Python.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages