Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Parwez07 committed Oct 28, 2022
1 parent da69f2e commit 2636c80
Show file tree
Hide file tree
Showing 13 changed files with 115 additions and 0 deletions.
7 changes: 7 additions & 0 deletions JavaScript/Dicegame/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#simple dice game using javascript

<p align="center">
<img src="/JavaScript/Dicegame/images/one.png" width="350" title="hover text">
<img src="/JavaScript/Dicegame/images/two.png" width="350" title="hover text">
<img src="/JavaScript/Dicegame/images/three.png" width="350" title="hover text">
</p>
37 changes: 37 additions & 0 deletions JavaScript/Dicegame/dicee.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<!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">
<img class="img1" src="images/dice6.png">
<p>Player 1</p>
</div>

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

</div>

<script src="index.js" charset="utf-8"></script>

</body>

<footer>
this is parwez
</footer>

</html>
Binary file added JavaScript/Dicegame/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 JavaScript/Dicegame/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 JavaScript/Dicegame/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 JavaScript/Dicegame/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 JavaScript/Dicegame/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 JavaScript/Dicegame/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.
Binary file added JavaScript/Dicegame/images/one.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 JavaScript/Dicegame/images/three.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 JavaScript/Dicegame/images/two.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 28 additions & 0 deletions JavaScript/Dicegame/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

var randomNumber1 = Math.floor(Math.random() * 6) + 1; //1-6

var randomDiceImage = "dice" + randomNumber1 + ".png"; //dice1.png - dice6.png

var randomImageSource = "images/" + randomDiceImage; //images/dice1.png - images/dice6.png

var image1 = document.querySelectorAll("img")[0];

image1.setAttribute("src", randomImageSource);

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

var randomImageSource2 = "images/dice" + randomNumber2 + ".png";

document.querySelectorAll("img")[1].setAttribute("src", randomImageSource2);


//If player 1 wins
if (randomNumber1 > randomNumber2) {
document.querySelector("h1").innerHTML = "🚩 Play 1 Wins!";
}
else if (randomNumber2 > randomNumber1) {
document.querySelector("h1").innerHTML = "Player 2 Wins! 🚩";
}
else {
document.querySelector("h1").innerHTML = "Draw!";
}
43 changes: 43 additions & 0 deletions JavaScript/Dicegame/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
.container {
width: 50%;
margin: auto;
text-align: center;
}

.dice {
padding-top: 80px;
text-align: center;
display: inline-block;

}

body {
background-color: #393E46;
}

h1 {
margin: 30px;
font-family: 'Lobster', cursive;
text-shadow: 5px 0 #232931;
font-size: 70px;
color: #4ECCA3;
}

p {
font-size: 2rem;
color: #4ECCA3;
font-family: 'Indie Flower', cursive;
}

img {

width: 70%;
}

footer {
margin-top: 5%;
color: #EEEEEE;
text-align: center;
font-family: 'Indie Flower', cursive;
float: left;
}

0 comments on commit 2636c80

Please sign in to comment.