This README file provides instructions and details about the Python-based Snake game developed using the Pygame module. The game features a background image, sound effects, and a high-score saving mechanism.
- Background Image: The background image (
bg.jpg) is displayed during gameplay. - Sound Effects:
gameover.mp3: Plays when the player loses the game.back.mp3: Plays as background music during gameplay.
- High Score Saving:
hiscore.txt: Stores the highest score achieved by the player.
- Game File:
- The main game script is named
Snake_Game.py.
- The main game script is named
To run the game, ensure you have the following installed on your system:
- Python (version 3.6 or higher)
- Pygame module
- Install it using the command:
pip install pygame
- Install it using the command:
Snake_Game.py: Main game script.bg.jpg: Background image used during the game.gameover.mp3: Sound effect for game over.back.mp3: Background music during gameplay.hiscore.txt: Text file to save the highest score.
- Clone or download the repository.
- Ensure all the required files (
bg.jpg,gameover.mp3,back.mp3,hiscore.txt) are in the same directory asSnake_Game.py. - Open a terminal or command prompt and navigate to the game directory.
- Run the game using the command:
python Snake_Game.py
- Use the arrow keys to move the snake.
- Collect food to grow the snake and increase the score.
- Avoid colliding with the walls or the snake’s own body.
- When the game ends, the highest score is saved in
hiscore.txt.
Replace bg.jpg with your desired background image. Ensure the file name and extension remain the same.
- Replace
gameover.mp3andback.mp3with your preferred audio files. - Ensure the file names and extensions remain unchanged.
To reset the high score, open hiscore.txt and replace its content with 0.
- Pygame: Used for rendering graphics, handling events, and managing the game loop.
Install it using:
pip install pygameThis project is open-source and can be used or modified for educational and personal purposes.
Muhammad Aqeel