Skip to content

Commit

Permalink
new-game
Browse files Browse the repository at this point in the history
  • Loading branch information
abdulshahvez committed May 12, 2024
1 parent 3e220e4 commit 2e56009
Show file tree
Hide file tree
Showing 10 changed files with 131 additions and 0 deletions.
1 change: 1 addition & 0 deletions Games/Dice-toss/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# DIceGame.github.io
33 changes: 33 additions & 0 deletions Games/Dice-toss/dicee.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>Dicee</title>
<link rel="stylesheet" href="styles.css">
<link href="https://fonts.googleapis.com/css?family=Indie+Flower|Lobster" rel="stylesheet">

</head>
<body>


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

<div class="dice">
<p>Player 1</p>
<img id="img1" src="images/dice2.png">
</div>

<div class="dice">
<p>Player 2</p>
<img id="img2" src="images/dice6.png">
</div>

</div>
<script src="index.js"></script>
</body>




</html>
Binary file added Games/Dice-toss/images/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 Games/Dice-toss/images/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 Games/Dice-toss/images/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 Games/Dice-toss/images/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 Games/Dice-toss/images/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 Games/Dice-toss/images/dice6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
56 changes: 56 additions & 0 deletions Games/Dice-toss/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
var randomnum1=Math.floor(Math.random()*6+1);

var randomnum2=Math.floor(Math.random()*6+1);

// For first dice(left)
if(randomnum1==1){
document.getElementById("img1").setAttribute('src','images/dice1.png');
}
else if(randomnum1==2){
document.getElementById("img1").setAttribute('src','images/dice2.png');
}
else if(randomnum1==3){
document.getElementById("img1").setAttribute('src','images/dice3.png');
}
else if(randomnum1==4){
document.getElementById("img1").setAttribute('src','images/dice4.png');
}
else if(randomnum1==5){
document.getElementById("img1").setAttribute('src','images/dice5.png');
}
else if(randomnum1==6){
document.getElementById("img1").setAttribute('src','images/dice6.png');
}



// For second dice (right)
if(randomnum2==1){
document.getElementById("img2").setAttribute('src','images/dice1.png');
}
else if(randomnum2==2){
document.getElementById("img2").setAttribute('src','images/dice2.png');
}
else if(randomnum2==3){
document.getElementById("img2").setAttribute('src','images/dice3.png');
}
else if(randomnum2==4){
document.getElementById("img2").setAttribute('src','images/dice4.png');
}
else if(randomnum2==5){
document.getElementById("img2").setAttribute('src','images/dice5.png');
}
else if(randomnum2==6){
document.getElementById("img2").setAttribute('src','images/dice6.png');
}

if(randomnum1>randomnum2){
document.querySelector("h1").innerHTML="Player1 wins!!";
}
else if(randomnum2>randomnum1){
document.querySelector("h1").innerHTML="Player2 wins!!";
}
else{
document.querySelector("h1").innerHTML="It's a Draw!.....try again";

}
41 changes: 41 additions & 0 deletions Games/Dice-toss/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
.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;

}

0 comments on commit 2e56009

Please sign in to comment.