Skip to content

Genius4Lyf/pig-game

Repository files navigation

Pig Game

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.

How to Play

The rules of Pig are straightforward:

  1. Players: The game is designed for two players.
  2. Turns: Players take turns rolling a single die.
  3. 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.
  4. 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.
  5. 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.
  6. New Game: Click the "New Game" button to reset all scores and start over.

Features

  • 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.

Technologies Used

  • HTML: For the basic structure and content of the game.
  • CSS: For styling the game interface.
  • JavaScript: For game logic, interactivity, and DOM manipulation.

How to Run Locally

  1. Clone the repository (or download the files):
    git clone <your-repository-url>
  2. Navigate to the project directory:
    cd <project-directory-name>
  3. Open index.html: Open the index.html file 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.

About

A simple and interactive web-based version of the classic dice game 'Pig'. Players take turns rolling a die to accumulate points, trying to be the first to reach a target score. Features include tracking current and total scores for two players, and options to roll the dice, hold the current score, or start a new game.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors