Skip to content

MhussainD4772/Snake-Game

Folders and files

NameName
Last commit message
Last commit date

Latest commit

e9be257 ยท Feb 8, 2025

History

5 Commits
Feb 8, 2025
Feb 8, 2025
Feb 8, 2025
Feb 8, 2025

Repository files navigation

๐Ÿ Snake Game โ€“ Python Tkinter Edition ๐ŸŽฎ๐Ÿ”ฅ

A modern, polished version of the classic Snake Game built using Python and Tkinter.


๐Ÿ“Œ Overview

This Snake Game is a fully interactive and animated version of the classic game.
It features smooth movement, collision detection, a pixel-style background grid, a fading Game Over animation, and a glowing food effect!


๐ŸŽจ Features

โœ… Smooth Movement โ€“ The snake moves fluidly without delays.
โœ… Collision Detection โ€“ The snake dies if it hits the walls or itself.
โœ… Growing Snake โ€“ The snake grows longer every time it eats food.
โœ… Glowing Food Effect โ€“ Food glows with a yellow outline for visibility.
โœ… Retro Grid Background โ€“ Adds a cool pixel-style effect.
โœ… Fading "Game Over" Animation โ€“ Red and black flashing text when the game ends.
โœ… Clean Code โ€“ Structured with separate files for logic (main.py, snake.py, food.py).


๐Ÿ› ๏ธ Installation & Setup

Follow these steps to run the game on your local machine.

1๏ธโƒฃ Clone the Repository

git clone https://github.com/MhussainD4772/Snake-Game.git
cd Snake-Game

2๏ธโƒฃ Run the Game

python main.py

Python's Tkinter is built-in, so no extra dependencies are required!


๐Ÿ“‚ Project Structure

SnakeGame/                <-- ๐Ÿ“Œ Main project folder
|โ€” .gitignore             <-- Ignores unnecessary files
|โ€” README.md              <-- This file
|โ€” main.py                <-- Main game logic (controls, movement, game loop)
|โ€” settings.py            <-- Game constants (width, height, speed, colors)
|โ€” snake.py               <-- Snake class (movement, growth)
|โ€” food.py                <-- Food class (spawning, glowing effect)
|โ€” __pycache__/           <-- (Ignored)
|โ€” .venv/                 <-- (Ignored)

๐ŸŽฎ How to Play

  • Arrow Keys โ†’ Move the snake in different directions.
  • Eat Food โ†’ The snake grows in length.
  • Avoid Walls & Yourself โ†’ Game over if you crash!

๐Ÿ–ผ๏ธ Code Documentation & Future Improvements

โœจ main.py (Game Logic)

"""
๐Ÿ Snake Game - Python Tkinter Edition
---------------------------------------
๐Ÿš€ Features:
- Smooth movement & collision detection
- Growing snake when eating food
- Glowing food effect for better visibility
- Pixel grid background for a retro feel
- Game over flashing animation

๐ŸŽฏ Future Improvements:
- ๐ŸŽต Add Sound Effects (Eating, Death)
- ๐Ÿ”„ Add a Restart Button (Instead of closing the game)
- ๐ŸŽจ Custom Snake Skins or Themes
"""

๐Ÿ snake.py (Snake Movement & Growth)

"""
๐Ÿ Snake Class - Controls the Snake's Movement & Growth
-------------------------------------------------------
โœ” Starts with 3 body parts
โœ” Moves in a fixed direction
โœ” Grows when eating food
โœ” Detects self-collision

๐ŸŽฏ Future Improvements:
- ๐ŸŽจ Custom Snake Skins (Change color dynamically)
- ๐Ÿ”„ Faster Speed Increase Over Time
"""

๐Ÿ food.py (Food Behavior & Spawning)

"""
๐Ÿ Food Class - Handles Food Spawning & Glowing Effect
-----------------------------------------------------
โœ” Randomly spawns food in grid positions
โœ” Food glows with a yellow outline
โœ” Snake grows upon eating food

๐ŸŽฏ Future Improvements:
- ๐Ÿ’ Different Types of Food (Bonus points, Speed Boost, etc.)
- ๐Ÿ”„ Randomized Food Movement (Make food move!)
"""

๐Ÿ‘๏ธ Future Improvements

โœ… Improved Collision Handling โ€“ Make walls bounce instead of killing the snake.
โœ… Custom Themes & Snake Skins โ€“ Choose different colors for the snake.
โœ… Sound Effects โ€“ Add eating, movement, and game over sounds.
โœ… Leaderboard System โ€“ Save and track high scores.
โœ… Restart Button โ€“ Allow restarting the game without closing it.


๐Ÿ“š License

This project is open-source and free to use. Feel free to improve or modify it! ๐Ÿš€


๐Ÿ‘จโ€๐Ÿ’ป Author

M. Hussain
๐Ÿ’ป Python Developer | ๐Ÿš€ Gaming Enthusiast | ๐ŸŽฎ Building Cool Projects

๐Ÿ”— GitHub: MhussainD4772


โญ Like This Project?

If you found this game useful, please give it a star โญ on GitHub!

git clone https://github.com/MhussainD4772/Snake-Game.git

๐Ÿ”ฅ Enjoy your Snake Game! Happy Coding! ๐Ÿ๐ŸŽฎ๐Ÿš€

About

Created a simple fun snake game

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages