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.
- 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
randommodule to ensure every game is unique.
- Programming Language: Python 3.x
- Graphics Library: Pygame
- Utilities:
timeandrandommodules for speed control and coordinate generation
| 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) |
main.py: Contains the complete source code, including thegame_loop(),user_score(), andgame_snake()functions.
-
Install Pygame: Open your terminal and run:
pip install pygame
-
Clone or Download: Download the
main.pyfile to your local machine. -
Execute the Script: Run the game using the following command:
python main.py
- Name: MH Nahid
- Contact: Send an Email
