This is a simple implementation of the classic Snake game using Python and the Pygame library.
- Python 3.x
- Pygame library
-
Clone the repository (if applicable) or download the project files.
-
Install the Pygame library:
pip install pygame
-
Navigate to the project directory:
cd /path/to/your/project -
Run the game:
python projekt.py
- Arrow Keys: Control the direction of the snake (Up, Down, Left, Right)
- ESC: Exit the game
- The snake moves continuously in the current direction.
- Use the arrow keys to change the direction of the snake.
- The snake grows in length each time it eats a fruit.
- The game ends if the snake collides with the walls or its own body.
The main game loop handles the following tasks:
- Processing user input (arrow keys to change direction)
- Updating the snake's position
- Checking for collisions (with walls or itself)
- Drawing the game elements (snake, fruit, score)
- Refreshing the game screen at a fixed frame rate
show_score(choice, color, font, size): Displays the current score on the screen.game_over(): Displays the game over screen and the final score, then exits the game.
This project is licensed under the MIT License. See the LICENSE file for details.
- This project uses the Pygame library for game development.