https://github.com/ahmad131554/pig-game
Pig Game is a two-player dice game where players roll to accumulate points. The first to 100 points wins. Built with HTML, CSS, and JavaScript.
https://github.com/ahmad131554/pig-game
beginner-project board-game css game html js pig-game roll-the-dice score-tracking web-game
Last synced: 3 months ago
JSON representation
Pig Game is a two-player dice game where players roll to accumulate points. The first to 100 points wins. Built with HTML, CSS, and JavaScript.
- Host: GitHub
- URL: https://github.com/ahmad131554/pig-game
- Owner: Ahmad131554
- License: mit
- Created: 2025-04-12T07:51:31.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-04-12T08:09:13.000Z (over 1 year ago)
- Last Synced: 2025-04-12T09:20:17.929Z (over 1 year ago)
- Topics: beginner-project, board-game, css, game, html, js, pig-game, roll-the-dice, score-tracking, web-game
- Language: CSS
- Homepage: https://rollthepig.netlify.app
- Size: 387 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# Pig Game
**Pig Game** is a simple, yet fun, multiplayer web-based game where two players take turns rolling dice and accumulate points. The first player to reach 100 points wins the game. The game offers interactive elements like dice rolling, holding points, and restarting the game. It's a great beginner-friendly project built with HTML, CSS, and JavaScript.
---
## Table of Contents
1. [Project Description](#project-description)
2. [Project Preview](#project-preview)
3. [Features](#features)
4. [Technologies Used](#technologies-used)
5. [Installation Instructions](#installation-instructions)
6. [Usage Instructions](#usage-instructions)
7. [License](#license)
---
## Project Description
The **Pig Game** is a dice-rolling game for two players. Players take turns rolling a dice and adding up points. On each turn, the player can choose to "Hold" and keep the current points or "Roll" the dice again. However, if the dice shows a 1, they lose the points accumulated on that turn. The first player to reach a score of 100 wins the game. The game features an option to start a new game at any time.
---
## Project Preview
You can view a live demo of the project here: [Pig Game Demo](https://rollthepig.netlify.app/)
---
## Features
- **Multiplayer Gameplay**: Two players take turns to play the game.
- **Dice Rolling**: Players can roll a dice to accumulate points, but a roll of "1" resets their turn's score.
- **Hold Mechanism**: Players can hold their accumulated points to add them to the total score.
- **Score Tracking**: The current score for both players is displayed, and the game continues until one player reaches 100 points.
- **Reset Feature**: Players can restart the game at any time with the "New game" button.
- **Visual Feedback**: Active player is highlighted, and the dice roll is shown visually.
---
## Technologies Used
- **HTML**: Used for the structure of the game and page layout.
- **CSS**: Provides the styling and visual design to make the game look appealing and interactive.
- **JavaScript**: Contains the logic for gameplay, dice rolls, score tracking, switching players, and managing the game state.
---
## Installation Instructions
1. **Clone this repository** to your local machine using the following command:
```bash
git clone https://github.com/yourusername/pig-game.git
```
2. **Navigate to the project folder:**
```bash
cd pig-game
```
3. **Open the index.html file** in your preferred browser to start playing the game.
You can open it locally by double-clicking the index.html file or by serving it using a local server.
---
## Usage Instructions
**Start the Game:** Open the index.html file in any modern browser to begin playing the game.
**Roll the Dice:** Click the "🎲 Roll dice" button to roll the dice and accumulate points for the current player.
**Hold the Points:** Click the "📥 Hold" button to keep the current points and add them to your total score.
**Switch Player:** After each turn, the active player switches, and the game continues until one player reaches 100 points.
**Restart the Game:** Click the "🔄 New game" button to reset the game and start fresh with scores set to 0.
---
## License
This project is licensed under the MIT License. See the [LICENSE](./LICENSE) file for more information.