A snake game with speed altering powerups and a two-player mode created using Python and Pygame, following object oriented principles. This project was created to practice game loops, class creation and usage, collision detection and menu creation using Pygame.
- Classic snake features (collision detection, fruit collection, snake growth)
- Two-player mode with collision checks between snakes
- Menus (Main menu and game over menu allowing access to single-player mode and two-player mode using buttons
- Time and score tracking (as well as high score tracking for each mode using a JSON file)
- Speed changing power ups (randomly spawning and altering game-speed when collected)
- Various sound effects (Fruit eaten, game over, powerup consumed, etc.)
Python 3.10+ (Developed and tested on Python 3.13.7)
Pygame 2.1.0+ (Developed and tested on version 2.6.1)
- Clone the repository:
git clone https://github.com/Ofek-Hodis/Snake
cd Snake - Install requirements (see above)
Example:
pip install pygame - Run the game:
Python run.py
For single-player, arrow-keys control the snake; use esc to close the game at any time.
For two-player mode, the same controls apply. Use WASD to control the second snake.
At any moment, 'esc' can be used to quit the game, 'r' to restart it and 'p' to pause it
- Control the snake using arrow keys.
- Eat apples and grow to increase your score.
- Eat powerups (marked by the purple questionmark) for a change of speed.
- Game ends if you collide with the walls or yourself.
- Blue snake: control using arrow keys, can only eat apples.
- Red snake: control using WASD, can only eat oranges.
- Eat powerups (marked by the purple question mark) for a change of speed.
- If a snake tries to eat the other snake's fruit, the fruit's location will be randomized without increasing the score or the snake's size.
- The game ends if either snake collides with the other, the walls or itself.
Snake/<Br>
├── Assets/ # Game assets (visuals and audio)<br>
│ ├── Fonts/ # Font files for UI and text display<br>
│ ├── Images/ # Game images (such as for the snake or fruit)<br>
│ └── Sounds/ # Sound effects<br>
├── Data/ # Persistent game data<br>
│ └── high_score.json # Stores player high scores<br>
├── src/ # Source code for game logic<br>
│ ├── button.py # Button handling logic for UI<br>
│ ├── main.py # Code for game and menu loops<br>
│ ├── main_classes.py # Core game classes (Main, Snake, Fruit...)<br>
│ └── support_funcs.py # Helper and utility functions<br>
├── .gitignore # Ignore files/folders not to be tracked by git<br>
├── LICENSE # License file (project usage rights)<br>
├── README.md # Project documentation and overview<br>
└── run.py # Module used to launch the game from the root
- Add three player game-mode.
- Additional powerups.
- Background music.