-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathDice.html
More file actions
90 lines (75 loc) · 2.27 KB
/
Dice.html
File metadata and controls
90 lines (75 loc) · 2.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8" />
<title>Dicee Game 🎲</title>
<!-- Google Fonts -->
<link href="https://fonts.googleapis.com/css?family=Indie+Flower|Lobster" rel="stylesheet" />
<!-- Internal CSS -->
<style>
.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;
}
</style>
</head>
<body>
<div class="container">
<h1>Refresh Me</h1>
<div class="dice">
<p>Player 1</p>
<img class="img1" src="https://raw.githubusercontent.com/AppBrewery/dicee/master/images/dice6.png" />
</div>
<div class="dice">
<p>Player 2</p>
<img class="img2" src="https://raw.githubusercontent.com/AppBrewery/dicee/master/images/dice6.png" />
</div>
</div>
<footer>www 🎲 App Brewery 🎲 com</footer>
<!-- Internal JavaScript -->
<script>
var random1 = Math.floor(Math.random() * 6) + 1;
var image1 = "https://raw.githubusercontent.com/AppBrewery/dicee/master/images/dice" + random1 + ".png";
document.querySelector(".img1").setAttribute("src", image1);
var random2 = Math.floor(Math.random() * 6) + 1;
var image2 = "https://raw.githubusercontent.com/AppBrewery/dicee/master/images/dice" + random2 + ".png";
document.querySelector(".img2").setAttribute("src", image2);
if (random1 > random2) {
document.querySelector("h1").innerHTML = "🚩 Player 1 Wins!";
} else if (random1 < random2) {
document.querySelector("h1").innerHTML = "Player 2 Wins! 🚩";
} else {
document.querySelector("h1").innerHTML = "Draw!";
}
</script>
</body>
</html>