JavaScript Dice Game

May 26, 2025

JavaScript Dice Game

Play the Game

How the Game Works

The Pig Dice Game is a simple push-your-luck dice game where players take turns rolling a die to score points, risking it all if they roll a 1. The fundemantals of the game like the singleplayer ui were implemented in the Udemy course: https://www.udemy.com/course/the-complete-javascript-course/

  1. Choose the number of players and start a new game.

  2. The first player clicks “Roll Dice” to add to their current score for the round. However, if they roll a 1, they lose all points accumulated in that round.
    If the player wants to keep their score, they can click “Hold” to add the current round score to their total.

  3. Players take turns following the same rules.
    The first player to reach 100 points wins the game.

Some Adjustments I made

Since the initial single-player game was already implemented in the Udemy course, I saw it as a great learning opportunity to adapt the code for a multiplayer option. I also created Game, Player, and Dice classes to practice object-oriented programming in JavaScript.

Thanks to my excellent programming professors at the University of Applied Sciences in Darmstadt, I already had experience with object-oriented programming in C++. Transferring that knowledge to JavaScript helped me better understand the differences between the two languages in the context of object-oriented programming.

I implemented a multiplayer mode that allows the user to choose the number of players (between 2 and 10). To support this feature, I modified both the UI and the game logic accordingly.

Contents