Welcome to Snake, a classic arcade game where you guide a growing snake to eat fruits and avoid obstacles. This project is an implementation of the iconic game in Python, developed with object-oriented programming principles.
- Features
- Installation
- Usage
- Images
- File Structure
- Technologies
- Contributing
- License
- About This Project
- Classic Snake gameplay with growing tail
- Multiple levels with increasing difficulty and obstacles
- Random fruit generation
- Game-over conditions for colliding with obstacles, walls, or the snake's own tail
- Graphical interface with intuitive keyboard controls
To run this project locally, follow these steps:
-
Clone the repository:
git clone https://github.com/SebaB29/Snake.git
-
Navigate to the project directory:
cd Snake
-
Run the game:
python main.py
Use the following controls to play the game:
- Left Arrow: Move left
- Right Arrow: Move right
- Up Arrow: Move up
- Down Arrow: Move down
- P: Pause
Avoid obstacles and eat fruits to grow longer!
The project structure is as follows:
Snake/
├── graphics/
│ ├── game_render.py
│ └── gamelib.py
├── img/
│ └── [2 demo images of the game]
├── resources/
│ └── obstacles.txt
├── src/
│ ├── constant.py
│ ├── event_controller.py
│ ├── fruit.py
│ ├── game.py
│ ├── obstacle_loader.py
│ ├── obstacle.py
│ ├── program.py
│ └── snake.py
├── .gitignore
├── LICENSE
├── main.py
└── README.md
- graphics/: Contains libraries for rendering the game (gamelib and custom graphics).
- img/: Includes demo images showcasing the game's functionality.
- resources/: Contains the obstacles configuration file (
obstacles.txt
). - src/: Includes source code files for game logic (snake, fruit, obstacles, and game flow).
- main.py: The entry point of the application.
This project is built with:
- Python
- Gamelib (A library created by the instructor to facilitate the use of threads and rendering for the interface)
Contributions are welcome! If you'd like to improve the game, feel free to fork the repository and submit a pull request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a pull request
Distributed under the MIT License. See LICENSE
for more information.
This project was developed as a practical assignment for university. It aims to implement the classic Snake game using Python, focusing on game logic and graphical interface through object-oriented programming principles.