A simple and interactive web-based version of the classic dice game "Pig". This project allows two players to compete by rolling a die to accumulate points, with the goal of being the first to reach a target score.
The rules of Pig are straightforward:
- Players: The game is designed for two players.
- Turns: Players take turns rolling a single die.
- Rolling the Die:
- On your turn, you can roll the die as many times as you wish. Each roll's value is added to your "Current" score for that turn.
- If you roll a 1, your "Current" score for that turn becomes 0, and your turn immediately ends. Play passes to the other player.
- Holding:
- You can choose to "Hold" at any point during your turn (as long as you haven't rolled a 1).
- If you hold, your "Current" score is added to your total "Score", and your turn ends. Play passes to the other player.
- Winning: The first player to reach a predetermined winning score (e.g., 100 points, though this is typically set in the JavaScript logic) wins the game.
- New Game: Click the "New Game" button to reset all scores and start over.
- Two-Player Gameplay: Supports two players, alternating turns.
- Score Tracking: Displays the total score for each player.
- Current Round Score: Shows the points accumulated in the current turn for the active player.
- Visual Dice: An image of a die updates to show the outcome of each roll.
- Interactive Controls:
- Roll Dice: Simulates rolling the die.
- Hold: Allows the current player to add their round score to their total score and pass the turn.
- New Game: Resets the game to its initial state.
- Active Player Indication: Visually highlights which player's turn it is.
- HTML: For the basic structure and content of the game.
- CSS: For styling the game interface.
- JavaScript: For game logic, interactivity, and DOM manipulation.
- Clone the repository (or download the files):
git clone <your-repository-url>
- Navigate to the project directory:
cd <project-directory-name>
- Open
index.html: Open theindex.htmlfile in your preferred web browser (e.g., Chrome, Firefox, Safari).
And that's it! You can now play the Pig Game.
This project was built as part of learning JavaScript and web development fundamentals.