Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
kashnx authored Jan 13, 2024
1 parent efe461a commit 0756cdc
Show file tree
Hide file tree
Showing 9 changed files with 100 additions and 0 deletions.
Binary file added dice1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added dice2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added dice3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added dice4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added dice5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added dice6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>DICE GAME</title>
<link rel="stylesheet" href="styles.css">

</head>
<body>
<div class="container">
<div head><h1>Refresh Me</h1></div>

<div class="game"><h3>Player 1</h3>
<img class="img1" src="dice6.png" width="100px">
</div>
<div class="game"><h3>Player 2</h3>
<img class="img2" src="dice6.png" width="100px">
</div>
<script src="index.js"></script>
</body>

</html>
49 changes: 49 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
var n=Math.floor(Math.random()*6)+1;
var n2=Math.floor(Math.random()*6)+1;
if (n===1) {
document.querySelector("img").setAttribute("src", "dice1.png");
}
else if (n===2) {
document.querySelector("img").setAttribute("src", "dice2.png");
}
else if (n===3) {
document.querySelector("img").setAttribute("src", "dice3.png");
}
else if (n===4) {
document.querySelector("img").setAttribute("src", "dice4.png");
}
else if (n===5) {
document.querySelector("img").setAttribute("src", "dice5.png");
}
else if (n===6) {
document.querySelector("img").setAttribute("src", "dice6.png");
}


if (n2===1) {
document.querySelectorAll("img")[1].setAttribute("src", "dice1.png");
}
else if (n2===2) {
document.querySelectorAll("img")[1].setAttribute("src", "dice2.png");
}
else if (n2===3) {
document.querySelectorAll("img")[1].setAttribute("src", "dice3.png");
}
else if (n2===4) {
document.querySelectorAll("img")[1].setAttribute("src", "dice4.png");
}
else if (n2===5) {
document.querySelectorAll("img")[1].setAttribute("src", "dice5.png");
}
else if (n2===6) {
document.querySelectorAll("img")[1].setAttribute("src", "dice6.png");
}

if(n>n2){
document.querySelector("h1").innerHTML="Player 1 Wins";}
else if(n<n2){
document.querySelector("h1").innerHTML="Player 2 Wins";}
else{
document.querySelector("h1").innerHTML="DRAW";}


29 changes: 29 additions & 0 deletions styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

h1 { font-family: "Brush Script MT", cursive; font-size: 24px; font-style: normal; font-variant: normal; font-weight: 700; line-height: 26.4px;
text-align: center;
margin-bottom: 50px;
font-size: 5rem;
color: rgb(11, 11, 0); }




body{
background-color: rgb(45, 153, 130);
}
.container{
display: inline-block;
margin-left: 30%;
width: 50%;

}
.game{
display: inline-block;
margin-top: 7%;
margin-left: 100px;

}
h3{
font-family: 'Indie Flower', cursive;
font-size: xx-large;
}

0 comments on commit 0756cdc

Please sign in to comment.