Snake Game ๐ is a simple arcade-style game built in Python using the Pygame library. The player controls a snake that moves around the screen, eating food to grow longer while avoiding collisions with walls or itself. The game includes scoring and sound effects making it a fun way to practice Python game development and event handling.
A classic Snake Game built with Python and Pygame.
Control the snake, eat food, grow longer, and avoid collisions with walls or yourself. Simple, fun, and addictive!
- Snake movement: Navigate using arrow keys (Up, Down, Left, Right).
- Food spawning: Randomly placed red blocks appear on the screen.
- Scoring system: Gain +10 points each time the snake eats food.
- Collision detection: Game ends if the snake hits the wall or itself.
- Restart/Quit option: Press
Qto quit the game gracefully. - Sound effect: Plays a ping sound when food is eaten (macOS default sound).
- Python 3.x
- Pygame library
Install dependencies:
pip install pygame-
- Clone or download repository
-
- Save script as snake_game.py
-
- Run the game:
-
- python snake_game.py
-
- Arrow Keys: Move the snake in the desired direction.
-
- Q Key: Quit the game after a short delay.
-
- +10 points per food
-
- Highest score tracked
-
- Snake: Green blocks that grow longer when food is eaten.
-
- Food: Red block randomly placed on the grid.
-
- Background: Yellow screen for contrast.
-
- Levels or increasing speed
-
- Persistent high scores
-
- Custom sound effects/themes
-
- The sound effect uses afplay (macOS). On other systems, replace with a suitable audio player or Pygameโs mixer module.
-
- Ensure your terminal/IDE supports running Pygame windows.