Skip to content

Commit 3634152

Browse files
committed
dicegame
1 parent b49cead commit 3634152

File tree

9 files changed

+110
-0
lines changed

9 files changed

+110
-0
lines changed
19 KB
Loading
16.7 KB
Loading
13.4 KB
Loading
19.2 KB
Loading
18.2 KB
Loading
15.6 KB
Loading

Dicegame/Ruhi14/index.html

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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="style.css">
7+
</head>
8+
<body>
9+
10+
<div class="container">
11+
<h1>Refresh Me</h1>
12+
13+
<div class="dice">
14+
<p>Player 1</p>
15+
<img class="img1" src="img/dice-six-faces-one.png">
16+
</div>
17+
18+
<div class="dice">
19+
<p>Player 2</p>
20+
<img class="img2" src="dice-six-faces-one.png">
21+
</div>
22+
23+
</div>
24+
<script src= "script.js" charset = "utf-8" ></script>
25+
26+
</body>
27+
28+
29+
</html>

Dicegame/Ruhi14/script.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+
}

Dicegame/Ruhi14/style.css

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

0 commit comments

Comments
 (0)