1 stable release
new 1.0.0 | Mar 23, 2025 |
---|
#60 in Games
85 downloads per month
9KB
70 lines
🎯 The Number Guessing Game 🎮
📝 Description
Welcome to the Number Guessing Game! This is a simple and fun command-line game where you guess a randomly generated number within a specified range. The game provides hints to help you find the correct number, and you can play as many times as you like.
Table of Contents
Features ✨
- Custom Range: Specify your own minimum and maximum values for the guessing range.
- Colored Output: Enjoy a colorful command-line interface (can be disabled).
- Hints: Get hints like "You're way too low!", or "You're way too high!" to guide your guesses.
- Play Again: After winning, you can choose to play again or exit the game.
Installation 🛠️
Prerequisites
- Rust installed on your system.
Steps
-
Clone the repository:
git clone https://github.com/dossdortival/number-guessing.git
-
Navigate to the project directory:
cd number-guessing
-
Build the project:
cargo build --release
-
(Optional) Install the game globally:
cargo install --path .
Usage 🚀
Running the Game
You can run the game in two ways:
-
Locally (without installing):
cargo run -- <min> <max>
Example 1 (default):
cargo run
Example 2:
cargo run -- 100 500
-
Globally (after installing):
number-guessing <min> <max>
Example 1 (default):
number-guessing
Example 2:
number-guessing 100 500
Command-Line Arguments
Argument | Description | Default |
---|---|---|
<min> |
The minimum number in the range. | 1 |
<max> |
The maximum number in the range. | 100 |
--no-color |
Disable colored output. | false |
Example with all options:
number-guessing 100 500 --no-color
How to Play 🎲
-
Start the Game:
- Run the game with your desired range (e.g.,
10 500
).
- Run the game with your desired range (e.g.,
-
Guess the Number:
- Enter your guess when prompted.
- The game will tell you if your guess is too small, too big, or correct.
-
Use Hints:
- If your guess is far to the secret number, you'll get a hint like "You're way too high or too low!".
-
Win the Game:
- When you guess the correct number, you'll see a victory message with the number of attempts it took.
-
Play Again:
- After winning, you can choose to play again or exit the game.
Contributing 🤝
We welcome contributions! If you'd like to contribute to this project, please follow these steps:
- Fork the repository.
- Create a new branch for your feature or bugfix.
- Make your changes and commit them.
- Push your changes to your fork.
- Submit a pull request.
Please ensure your code follows the project's style and includes appropriate tests.
License 📄
This project is licensed under the MIT License. See the LICENSE file for details.
Acknowledgments 🙏
- Built with Rust.
- Uses the clap crate for command-line argument parsing.
- Inspired by the classic number-guessing game from "The Book".
Enjoy the game! 🚀 If you have any questions or feedback, feel free to open an issue or reach out.
Dependencies
~1.4–8.5MB
~70K SLoC