๐ฒ Dice Race: Player vs Computer
Dice Race is a fun and simple game where you compete against the computer to see who can reach the finish line first. Roll the dice, move forward, and may the luckiest player win!
๐ How to Play
- Click the "Roll Dice" button to roll a six-sided die.
- Your token moves forward based on the number rolled.
- The computer takes its turn automatically.
- The first to reach the final cell wins the game!
๐ Project Structure
dice_race/
โ-- index.html
โ-- styles.css
โ-- script.js
๐ How the Game Works
-
Game Setup:
- The game board consists of 25 cells, numbered 1 to 25.
- The player and computer each have a token starting at position 0.
-
Gameplay:
- Click "Roll Dice" to roll a 6-sided die.
- Your token moves forward based on the dice roll.
- After your turn, the computer rolls the dice and moves its token.
- The first to reach the 25th cell wins!
-
Winning Condition:
- If the player or computer reaches the last cell (cell 25), they win the game.
-
Reset:
- Click "Reset Game" to start a new game.
๐ง What You'll Learn
- HTML/CSS: Creating a grid-based board layout.
- JavaScript: Implementing game logic, handling user interactions, and updating the DOM dynamically.
-
Randomness: Using
Math.random()
to simulate dice rolls. - State Management: Keeping track of player and computer positions.
๐ฎ Play the Game
Simply open index.html
in your browser to play Dice Race!
Top comments (0)