sanjaysah

Sanjay Kumar Sah

Posted on September 30, 2024

PIG GAME 🐗

This is a submission for the Web Game Challenge, Build a Game: Alien Edition

What I Built

I built an exciting web game called PIG GAME! It's a simple dice game first described in print by John Scarne in 1945. The game is easy to pick up but requires some strategy and luck to win. I implemented it as a fun exercise to practice HTML, CSS, and JavaScript.

Tech Stack 🛠️

  • HTML5: Structuring the basic elements of the game.
  • CSS3: Styling the game interface for an engaging user experience.
  • JavaScript (ES6): Handling the game logic, dice rolls, and user interactions.

The project was a great opportunity to refine my DOM manipulation skills and event handling in JavaScript.

RULES📃TO PLAY GAME

Each turn, a player repeatedly rolls a die until either a 1 is rolled or the player decides to “hold”:

  • If the player rolls a 1, they score nothing and it becomes the next player's turn.
  • If the player rolls any other number, it is added to their turn total and the player's turn continues.
  • If a player chooses to “hold”, their turn total is added to their score, becoming the next player's turn.
  • Variation we used, if you roll snake eyes (both 1's), your total score from past rounds is reset to 0.

The first player to score 100 or more points wins.

Features ✨

  • Dynamic Score Updates: The score and dice rolls update live as the player plays.
  • Winning Screen: A celebratory message displays when a player wins the game.
  • Snake Eyes Reset Rule: Rolling double ones adds an element of risk, making the game more challenging.

Demo

You can play the Pig game here!

Journey

I built this game using HTML, CSS, and JavaScript as part of a project to enhance my front-end development skills. One of the main challenges was figuring out the logic for handling different game states, such as when the player should roll when they should hold, and how to implement the snake eyes rule.

Additionally, I spent time optimizing the user interface to be responsive and intuitive, ensuring players could enjoy the game on different devices.

This project helped me to improve my understanding of event-driven programming in JavaScript and how to manage state changes in a small game application.

💖 💪 🙅 🚩
sanjaysah
Sanjay Kumar Sah

Posted on September 30, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

CreateJS - One byte explainer
devchallenge CreateJS - One byte explainer

September 29, 2024

One Byte Explainer
devchallenge One Byte Explainer

September 29, 2024

Starcraft Next.js
devchallenge Starcraft Next.js

September 26, 2024

300LOC space life protect
devchallenge 300LOC space life protect

September 27, 2024

Web Audio API: Bring Games to Life with Sound
devchallenge Web Audio API: Bring Games to Life with Sound

September 23, 2024