A simple two-player dice game built with vanilla JavaScript. Players take turns rolling a dice to accumulate points, but rolling a 1 resets their current score. The first player to reach 100 points wins.
This project demonstrates core JavaScript concepts like DOM manipulation, event handling, and game logic.
- ๐ฒ Two-player game: Players take turns to roll a dice and accumulate points.
- โ Rolling a 1 resets the current score: Rolling a 1 will reset the playerโs round score, and the turn is passed to the next player.
- ๐ Winning condition: The first player to reach 100 points wins the game.
- ๐ฑ๏ธ Interactive buttons: Includes buttons for rolling the dice, holding the score, and resetting the game.
- ๐ป Vanilla JavaScript: Built with modern JavaScript using DOM manipulation and event handling.
- Roll the dice: Click on the "Roll Dice" button to roll the dice. The result is added to your current score unless you roll a 1.
- Hold your score: Click "Hold" to save your current score to your total score. Itโs then the next player's turn.
- Watch out for the 1!: If you roll a 1, your current score is reset, and your turn ends.
- Win the game: Be the first player to reach 100 points to win!
- HTML
- CSS
- JavaScript (Vanilla JS)
This project is structured using the MVC (Model-View-Controller) architecture, which helps in organizing the code and separating concerns.
- Model: Represents the data and the business logic of the application.
- View: Handles the presentation layer, displaying the user interface.
- Controller: Manages user input and interacts with both the Model and View to update the UI accordingly.
You can play the game live here
-
Clone the repository:
git clone https://github.com/HassaniDev/Dice-Game.git
-
Navigate to the project folder
cd dice-game
-
Open the
index.html
file with a live server (e.g., using the Live Server extension in VS Code) to start playing, or just Open theindex.html
file in your browser to start playing.
If you prefer to play the game without sound, please feel free to mute your browser tab or computer. The button click sound is included to enhance the experience, but your enjoyment is what matters most! ๐ฎ
- โ๏ธ Add more game settings (e.g., changing the target score).
- ๐ฎ Implement single-player mode.
- ๐ฑ Improve mobile responsiveness.
- ๐ต Add background soft music to enhance focus, with an option for the player to disable or mute the music.
- ๐ Dark Theme: Currently, the game only supports a light theme. A dark theme option will be implemented in future updates for better user customization.
This game uses fonts from Google Fonts, which require an active internet ๐ connection. Please ensure that your Wi-Fi ๐ or internet ๐ connection is turned on for the fonts to load correctly and for the best experience.
- Hassani (Owner)
- Jonas Schmedtmann for the JavaScript course that inspired this project.
- GitHub Copilot for assistance with coding and documentation.
This project is licensed under the MIT License - see the LICENSE file for details.