This repository contains a simple Snake game implemented using the pygame library. The game features basic mechanics where the player controls a snake to eat food and grow, while avoiding collisions with the walls and itself.
The Snake Game provides a classic arcade experience where the player manoeuvres a snake around the screen, collects food, and avoids obstacles. The game is displayed using a graphical interface provided by pygame.
- Classic Snake Gameplay: Control the snake to eat food and grow longer.
- Score Display: Shows the current score based on the length of the snake.
- Game Over Handling: The game displays a message and allows the player to restart or quit.
- Food Generation: Randomly places food on the screen.
- Python 3.x
pygame(install via pip install -r requirements.txt)
- Clone this Repository:
git clone https://github.com/Myszanik/SnakeGame.git
- Navigate to the Project Directory:
cd SnakeGame
- Create and activate a virtual environment (recommended):
python -m venv .venv.\.venv\Scripts\Activate.ps1
- Install Dependencies:
python -m pip install -r requirements.txt
- Run the Game:
python snake_game.py
Your_score(score): Renders the current score on the screen.our_snake(snake_block, snake_list): Draws the snake on the screen.message(msg, color): Displays a message on the screen.gameLoop(): Contains the main game logic, including event handling, snake movement, collision detection, and game over conditions.
- Start the Game: Run the script, and the game window will appear.
- Control the Snake: Use the arrow keys to control the direction of the snake (left, right, up, down).
- Eat Food: Navigate the snake to the food to grow longer and increase your score.
- Avoid Collisions: Avoid running into the walls or the snake's own body to prevent a game over.
- Game Over: When the game is over, press
ESCto quit orSpaceBarto restart the game.
pygamefor providing a simple and powerful library for game development in Python.
This project is still in development. Features and functionality may be subject to change, and there may be some incomplete or experimental features. Contributions and feedback are welcome!