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 @@ + + + + + + + + + Dice Game + + + +
+

Let's Start

+ +
+

Player 1

+ +
+ +
+

Player 2

+ +
+
+ +
+ +
+
+ +
+ + diff --git a/Dice_Game/style.css b/Dice_Game/style.css new file mode 100644 index 00000000..8233af04 --- /dev/null +++ b/Dice_Game/style.css @@ -0,0 +1,55 @@ + + .container { + width: 70%; + margin: auto; + text-align: center; + } + + .dice { + text-align: center; + display: inline-block; + margin: 10px; + } + + body { + background-color: #042f4b; + margin: 0; + } + + h1 { + margin: 30px; + font-family: "Lobster", cursive; + text-shadow: 5px 0 #232931; + font-size: 4.5rem; + color: #4ecca3; + text-align: center; + } + + p { + font-size: 2rem; + color: #4ecca3; + font-family: "Indie Flower", cursive; + } + + img { + width: 100%; + } + + .bottom { + padding-top: 30px; + } + + .butn { + background: #4ecca3; + font-family: "Indie Flower", cursive; + border-radius: 7px; + color: #ffff; + font-size: 30px; + padding: 16px 25px 16px 25px; + text-decoration: none; + } + + .butn:hover { + background: #232931; + text-decoration: none; + }