This is a multiplayer number guessing game built using Python's tkinter
library. It includes a game menu, multiplayer support, difficulty levels, a countdown timer, and a high score feature that tracks the best performance across games.
- Multiplayer Mode: Two players take turns guessing the number.
- Difficulty Levels:
- Easy (60 seconds)
- Medium (30 seconds)
- Hard (15 seconds)
- High Score Tracking: The game records and displays the best performance (minimum total attempts) across all games.
- Countdown Timer: Keeps the game engaging by adding a time limit based on the selected difficulty.
- Hints System: Provides hints ("Too low!" or "Too high!") to guide players.
- Graphical User Interface (GUI): Built using
tkinter
for a user-friendly experience.
Ensure you have Python installed on your system. This game uses the tkinter
library, which comes pre-installed with Python.
git clone https://github.com/aref-asadi/number-guessing-game.git
cd number-guessing-game
Execute the following command in your terminal to start the game:
python number_guessing_game.py
- Launch the Game: Run the script to open the game menu.
- Enter Player Names: Input names for Player 1 and Player 2.
- Select Difficulty: Choose a difficulty level to set the countdown timer.
- Start the Game: Press "Start Game" to begin.
- Guess the Number:
- Players take turns guessing a number between 1 and 100.
- The game provides hints after each guess.
- Win or Lose:
- If a player guesses the number correctly, the game ends, and the total attempts are recorded.
- If the timer runs out, the game ends, and you can return to the menu.
- The game saves the high score (minimum total attempts across both players) to a
highscore.txt
file. - If a new high score is achieved, it will be saved and displayed in the game menu.
.
├── number_guessing_game.py # Main game file
├── highscore.txt # File for storing high score (generated at runtime)
├── LICENSE # License file
└── README.md # Readme file
- High Score File: The high score is saved in
highscore.txt
. You can change the file name or location by modifying thesave_high_score
andload_high_score
methods. - Difficulty Settings: Adjust the time limits for each difficulty in the
start_game
method.
Contributions are welcome! Feel free to fork the repository and submit a pull request.
- Fork the repository.
- Create a new branch (
git checkout -b feature-branch-name
). - Clone your fork (
git clone https://github.com/your-username/number-guessing-game.git
) - Chnage your directory (
cd number-guessing-game
) - Commit your changes (
git commit -m 'Add a new feature'
). - Push to the branch (
git push origin feature-branch-name
). - Open a pull request.
This project is licensed under the GNU General Public License v3.0.