Skip to content

mh-nahid/Snake-Game-Python-

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

🐍 Snake Game using Python (Pygame)

A classic, interactive Snake Game built with Python and the Pygame library. This project serves as a practical implementation of game development fundamentals, including movement logic, collision detection, and persistent scoring.


🎮 Features

  • Classic Arcade Mechanics: Maneuver the snake to collect food while its length increases with every meal.
  • Real-time Score Tracking: A dynamic score display is positioned at the top-left to track your progress during gameplay.
  • Collision Logic: The game monitors window boundaries; hitting a wall triggers a Game Over state.
  • Post-Game Controls: After a loss, players can quickly restart by pressing C or exit the game by pressing Q.
  • Responsive Navigation: Smooth movement control is mapped directly to the keyboard's arrow keys.
  • Randomized Food Spawning: Food appears at random coordinates using Python's random module to ensure every game is unique.

🛠️ Technology Stack

  • Programming Language: Python 3.x
  • Graphics Library: Pygame
  • Utilities: time and random modules for speed control and coordinate generation

🕹️ Controls & Gameplay

Action Control
Move Up Up Arrow Key
Move Down Down Arrow Key
Move Left Left Arrow Key
Move Right Right Arrow Key
Play Again Press C (after losing)
Quit Game Press Q (after losing)

📸 Output Preview

Snake Game Screenshot

📁 Project Structure

  • main.py: Contains the complete source code, including the game_loop(), user_score(), and game_snake() functions.

💻 How to Run

  1. Install Pygame: Open your terminal and run:

    pip install pygame
  2. Clone or Download: Download the main.py file to your local machine.

  3. Execute the Script: Run the game using the following command:

    python main.py

👤 Author

About

A classic, interactive Snake Game built with Python and the Pygame library. This project serves as a practical implementation of game development fundamentals, including movement logic, collision detection, and persistent scoring.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages