Skip to content

About

An interactive, browser-based two-player dice game built with vanilla JavaScript, featuring dynamic DOM manipulation and advanced state logic from Jonas Schmedtmann's The Complete JavaScript Course.

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pig Game

A classic dice game built while following Jonas Schmedtmann's The Complete JavaScript Course.

🎮 About the Project

This is my third complete JavaScript project. Players take turns rolling a dice and can choose to "Hold" their current score or continue rolling. If a player rolls a 1, they lose their current points and the turn passes to the other player. First to reach 100 points wins!

✨ Features

  • Turn-based gameplay with two players
  • Roll dice and accumulate points
  • Hold current score to bank points
  • Win condition (first to 100 points)
  • Clean UI with active player highlighting
  • Reset game functionality
  • Click sound feedback on button actions

🛠️ Technologies Used

  • HTML5
  • CSS3
  • Vanilla JavaScript (DOM manipulation, event handling, game logic, sound)

📖 History of the Game

The Pig Game is a simplified version of traditional dice games that date back centuries. The modern "Pig" dice game was popularized in the mid‑20th century as a quick, easy‑to‑learn family game. Its appeal lies in the balance between risk and reward: players must decide whether to keep rolling for more points or "hold" to secure their score, knowing that a single unlucky roll can wipe out their progress.

The game has been used in classrooms to teach probability and decision‑making, and it remains a staple in beginner programming courses because its rules are simple yet perfect for practicing loops, conditionals, and state management. By recreating Pig in JavaScript, learners get hands‑on experience with DOM manipulation, event‑driven programming, and building interactive web apps.

📸 Preview

Live Preview

🚀 How to Play

  1. Click Roll Dice to roll
  2. Click Hold to save your current points
  3. First player to reach 100 points wins!
  4. Rolling a 1 loses your current turn points

🧠 Learning Outcomes

  • DOM manipulation
  • Event listeners
  • Game state management
  • JavaScript logic and refactoring
  • Working with classes and dynamic UI updates
  • Adding sound and visual feedback

Built as part of my self‑taught JavaScript journey in 2026.
📅 Last updated: 1 May 2026, 19:32 (WAT)

Feedback and suggestions are welcome!


About

An interactive, browser-based two-player dice game built with vanilla JavaScript, featuring dynamic DOM manipulation and advanced state logic from Jonas Schmedtmann's The Complete JavaScript Course.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages