diff --git a/Dice_Game/dice.js b/Dice_Game/dice.js new file mode 100644 index 00000000..53516019 --- /dev/null +++ b/Dice_Game/dice.js @@ -0,0 +1,43 @@ + + // Player name + var player1 = "Player 1"; + var player2 = "Player 2"; + + // Function to change the player name + function editNames() { + player1 = prompt("Change Player1 name"); + player2 = prompt("Change player2 name"); + + document.querySelector("p.Player1").innerHTML = player1; + document.querySelector("p.Player2").innerHTML = player2; + } + + // Function to roll the dice + function rollTheDice() { + setTimeout(function () { + var randomNumber1 = Math.floor(Math.random() * 6) + 1; + var randomNumber2 = Math.floor(Math.random() * 6) + 1; + + document.querySelector(".img1").setAttribute("src", + "dice" + randomNumber1 + ".png"); + + + document.querySelector(".img2").setAttribute("src", + "dice" + randomNumber2 + ".png"); + + if (randomNumber1 === randomNumber2) { + document.querySelector("h1").innerHTML = "Draw!"; + } + + else if (randomNumber1 < randomNumber2) { + document.querySelector("h1").innerHTML + = (player2 + " WINS!"); + } + + else { + document.querySelector("h1").innerHTML + = (player1 + " WINS!"); + } + }, 2500); + } + diff --git a/Dice_Game/diceimage.jpeg b/Dice_Game/diceimage.jpeg new file mode 100644 index 00000000..52fc84e6 Binary files /dev/null and b/Dice_Game/diceimage.jpeg differ diff --git a/Dice_Game/img1/dice1.png b/Dice_Game/img1/dice1.png new file mode 100644 index 00000000..5aed1281 Binary files /dev/null and b/Dice_Game/img1/dice1.png differ diff --git a/Dice_Game/img1/dice2.png b/Dice_Game/img1/dice2.png new file mode 100644 index 00000000..90e3290d Binary files /dev/null and b/Dice_Game/img1/dice2.png differ diff --git a/Dice_Game/img1/dice3.png b/Dice_Game/img1/dice3.png new file mode 100644 index 00000000..985316ca Binary files /dev/null and b/Dice_Game/img1/dice3.png differ diff --git a/Dice_Game/img1/dice4.png b/Dice_Game/img1/dice4.png new file mode 100644 index 00000000..df6b6b69 Binary files /dev/null and b/Dice_Game/img1/dice4.png differ diff --git a/Dice_Game/img1/dice5.png b/Dice_Game/img1/dice5.png new file mode 100644 index 00000000..30df0bef Binary files /dev/null and b/Dice_Game/img1/dice5.png differ diff --git a/Dice_Game/img1/dice6.png b/Dice_Game/img1/dice6.png new file mode 100644 index 00000000..8fd20f6e Binary files /dev/null and b/Dice_Game/img1/dice6.png differ diff --git a/Dice_Game/img2/dice1.png b/Dice_Game/img2/dice1.png new file mode 100644 index 00000000..5aed1281 Binary files /dev/null and b/Dice_Game/img2/dice1.png differ diff --git a/Dice_Game/img2/dice2.png b/Dice_Game/img2/dice2.png new file mode 100644 index 00000000..90e3290d Binary files /dev/null and b/Dice_Game/img2/dice2.png differ diff --git a/Dice_Game/img2/dice3.png b/Dice_Game/img2/dice3.png new file mode 100644 index 00000000..985316ca Binary files /dev/null and b/Dice_Game/img2/dice3.png differ diff --git a/Dice_Game/img2/dice4.png b/Dice_Game/img2/dice4.png new file mode 100644 index 00000000..df6b6b69 Binary files /dev/null and b/Dice_Game/img2/dice4.png differ diff --git a/Dice_Game/img2/dice5.png b/Dice_Game/img2/dice5.png new file mode 100644 index 00000000..30df0bef Binary files /dev/null and b/Dice_Game/img2/dice5.png differ diff --git a/Dice_Game/img2/dice6.png b/Dice_Game/img2/dice6.png new file mode 100644 index 00000000..8fd20f6e Binary files /dev/null and b/Dice_Game/img2/dice6.png differ diff --git a/Dice_Game/index.html b/Dice_Game/index.html new file mode 100644 index 00000000..1f98f730 --- /dev/null +++ b/Dice_Game/index.html @@ -0,0 +1,41 @@ + + + +
+ + + + +Player 1
+ +Player 2
+ +