Skip to content

A fun and interactive two-player dice game built using HTML, CSS, and JavaScript. Players take turns rolling a die, accumulating points, and holding scores strategically. The first to reach 100 wins.

Notifications You must be signed in to change notification settings

nanthakumar-m/Pig_Game-Html-Css-Javascript

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🐷 Pig Game – Dice Rolling Game (2-Player)

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.

⚙️ Technologies Used

  • HTML5
  • CSS3
  • JavaScript

💡Core Features

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

🎯 What I Gained / Concepts Practiced

✅ 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

📸 Screenshots

image

image

image

image

About

A fun and interactive two-player dice game built using HTML, CSS, and JavaScript. Players take turns rolling a die, accumulating points, and holding scores strategically. The first to reach 100 wins.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published