Skip to content

Commit 4082692

Browse files
authored
Merge pull request #761 from shivam200446/Dice_game
Dice game
2 parents f1703a5 + aab677a commit 4082692

File tree

9 files changed

+120
-0
lines changed

9 files changed

+120
-0
lines changed

Dicegame/shivam200446/dice.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
var randomnum1 = Math.floor(Math.random() * 6) + 1;
2+
var randomimg = "dice" + randomnum1 + ".png";
3+
var imgsource1 = "images/" + randomimg;
4+
var image1 = document.querySelectorAll("img")[0].setAttribute("src", imgsource1);
5+
6+
var randomnum2 = Math.floor(Math.random() * 6) + 1;
7+
var imgsource2 = "images/" +"dice" + randomnum2 + ".png";
8+
var image2 = document.querySelectorAll("img")[1].setAttribute("src", imgsource2);
9+
10+
if(randomnum1>randomnum2){
11+
document.querySelector("h1").innerHTML ="Player1 Wins!";
12+
}
13+
else if(randomnum1<randomnum2){
14+
document.querySelector("h1").innerHTML="Player2 Wins!";
15+
}
16+
else{
17+
document.querySelector("h1").innerHTML= "DRAW!";
18+
}
2.5 KB
Loading
2.16 KB
Loading
2.38 KB
Loading
2.55 KB
Loading
2.76 KB
Loading
2.91 KB
Loading

Dicegame/shivam200446/index.html

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<!DOCTYPE html>
2+
<html lang="en" dir="ltr">
3+
<head>
4+
<meta charset="utf-8">
5+
<title>Dicee</title>
6+
<link rel="stylesheet" href="styles.css">
7+
<link href="https://fonts.googleapis.com/css?family=Indie+Flower|Lobster" rel="stylesheet">
8+
9+
</head>
10+
<body>
11+
12+
<div class="container">
13+
<h1>Refresh Me</h1>
14+
15+
<div class="dice">
16+
<p>Player 1</p>
17+
<img class="img1" src="images/dice1.png">
18+
</div>
19+
20+
<div class="dice">
21+
<p>Player 2</p>
22+
<img class="img2" src="images/dice1.png">
23+
</div>
24+
25+
</div>
26+
<script src= "dice.js" charset = "utf-8" ></script>
27+
28+
</body>
29+
30+
31+
</html>

Dicegame/shivam200446/styles.css

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/* Reset some default styles */
2+
body {
3+
margin: 0;
4+
padding: 0;
5+
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
6+
background-color: #1f1f1f;
7+
color: #fff;
8+
}
9+
10+
/* Style the container */
11+
.container {
12+
text-align: center;
13+
margin: 50px auto;
14+
max-width: 400px;
15+
background-color: rgba(255, 255, 255, 0.1);
16+
padding: 30px;
17+
border-radius: 20px;
18+
box-shadow: 0 0 20px rgba(0, 0, 0, 0.4);
19+
}
20+
21+
/* Style the heading */
22+
h1 {
23+
font-family: 'Indie Flower', cursive;
24+
font-size: 48px;
25+
color: #ff6b6b;
26+
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.4);
27+
margin-bottom: 20px;
28+
}
29+
30+
/* Style the dice sections */
31+
.dice {
32+
margin-top: 20px;
33+
display: flex;
34+
flex-direction: column;
35+
align-items: center;
36+
}
37+
38+
/* Style the player names */
39+
.dice p {
40+
font-family: 'Lobster', cursive;
41+
font-size: 32px;
42+
color: #ff6b6b;
43+
margin: 10px 0;
44+
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.4);
45+
}
46+
47+
/* Style the dice images */
48+
.img1,
49+
.img2 {
50+
width: 150px;
51+
height: 150px;
52+
margin-top: 20px;
53+
filter: drop-shadow(2px 2px 4px rgba(0, 0, 0, 0.4));
54+
transition: transform 0.3s ease-in-out;
55+
}
56+
.img1:hover,
57+
.img2:hover {
58+
transform: rotate(180deg) scale(1.1);
59+
}
60+
.dice-background {
61+
position: absolute;
62+
top: 50%;
63+
left: 50%;
64+
transform: translate(-50%, -50%);
65+
width: 200px;
66+
height: 200px;
67+
background: url('your-custom-dice-background.png') no-repeat;
68+
background-size: cover;
69+
opacity: 0.2;
70+
z-index: -1;
71+
}

0 commit comments

Comments
 (0)