Pig Game is a simple yet engaging 2-player dice game built using HTML, CSS, and vanilla JavaScript. The goal is to simulate turn-based gameplay where each player rolls a dice, accumulates points, and tries to reach 100 points to win — but rolling a 1 resets their turn score!
This project was developed to strengthen my JavaScript fundamentals and logical thinking, while also gaining hands-on experience with DOM manipulation, event handling, and game state control.
🔗👉 click here to see the live demo-->https://nanthakumar-m.github.io/Pig_Game-Html-Css-Javascript/
🚫 Note: This website is not responsive and is best viewed on desktop screens.
- HTML5
- CSS3
- JavaScript
✅ Roll Dice: Random number generation with real-time dice image updates.
✅ Score Accumulation: Add dice values to current score unless a 1 is rolled.
✅ Player Switch: Automatically switches turns on rolling a 1 or pressing "Hold".
✅ Win Detection: Player wins when their total score reaches 100.
✅ New Game Button: Resets all values and restarts the game.
✅ DOM Manipulation and Event Binding
✅ Working with game state (activePlayer, scores, currentScore)
✅ Implementing conditional game logic and dynamic UI changes
✅ Creating reusable functions (switchPlayer, initial)
✅ Managing classes dynamically using classList.toggle, classList.add/remove
✅ Random number generation