Add files via upload

Added a dice game
pull/953/head
Shreyan-12345 3 years ago committed by GitHub
parent df13886eb7
commit 14afee8772
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

@ -0,0 +1,47 @@
.container {
width: 70%;
margin: auto;
text-align: center;
}
.dice {
text-align: center;
display: inline-block;
}
body {
background-color: #393E46;
}
h1 {
margin: 30px;
font-family: 'Lobster', cursive;
text-shadow: 5px 0 #232931;
font-size: 8rem;
color: #4ECCA3;
}
p {
font-size: 2rem;
color: #4ECCA3;
font-family: 'Indie Flower', cursive;
}
img {
width: 80%;
}
footer {
margin-top: 5%;
color: #EEEEEE;
text-align: center;
font-family: 'Indie Flower', cursive;
}
.but{
margin-left: 745px;
margin-top: 16px;
}

@ -0,0 +1,32 @@
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>Dicee</title>
<link rel="stylesheet" href="/Dice Game/dice.css">
<link href="https://fonts.googleapis.com/css?family=Indie+Flower|Lobster" rel="stylesheet">
</head>
<body>
<div class="container">
<h1 class="h1">Refresh Me</h1>
<div class="dice">
<p>Player 1</p>
<img class="img1" src="Images/dice6.png">
</div>
<div class="dice">
<p>Player 2</p>
<img class="img2" src="Images/dice6.png">
</div>
</div>
<button type="button" class="but">Play</button>
<script src="\Dice Game\dice.js" charset="utf-8"></script>
</body>
</html>

@ -0,0 +1,22 @@
const button = document.querySelector(".but");
button.addEventListener('click', (e) => {
e.preventDefault();
const randomNumber1 = Math.ceil(Math.random()*6);
const randomNumber2 = Math.ceil(Math.random()*6);
const img1 = document.querySelector(".img1");
const img2 = document.querySelector(".img2");
img1.src = `Images/dice${randomNumber1}.png`;
img2.src = `Images/dice${randomNumber2}.png`;
if(randomNumber1>randomNumber2)
{
document.querySelector("h1").innerHTML = "Player 1 Wins!";
}
else if(randomNumber1<randomNumber2)
{
document.querySelector("h1").innerHTML = "Player 2 Wins!";
}
else if(randomNumber1==randomNumber2)
{
document.querySelector("h1").innerHTML = "Draw!";
}
})
Loading…
Cancel
Save