-
Notifications
You must be signed in to change notification settings - Fork 0
/
rps.html
227 lines (226 loc) · 7.91 KB
/
rps.html
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
<!DOCTYPE html>
<html lang="en">
<head>
<title>PlayGame</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
/>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
<style>
.row{
padding-top: 80px;
padding-bottom: 99px;
}
#img1,#img2{
text-align: center;
height: 300px;
line-height: 300px;
font-size:50px;
}
#rps1,#rps2{
text-align: center;
font-size:30px;
color: rgb(83, 54, 54);
margin-bottom: 50px;
}
#result{
height: 255px;
text-align: center;
line-height: 255px;
font-family: Impact, Haettenschweiler, 'Arial Narrow Bold', sans-serif;
font-size: 80px;
color: rgb(83, 54, 54);
}
</style>
</head>
<body>
<header>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<a class="navbar-brand" href="./game.html">PlayGame</a>
<button
class="navbar-toggler"
type="button"
data-toggle="collapse"
data-target="#navbarScroll"
aria-controls="navbarScroll"
aria-expanded="false"
aria-label="Toggle navigation"
>
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarScroll">
<ul
class="navbar-nav mr-auto my-2 my-lg-0 navbar-nav-scroll"
style="max-height: 100px"
>
<li class="nav-item ">
<a class="nav-link" href="./game.html">Home</a
>
</li>
<li class="nav-item">
<a class="nav-link" href="./lotto.html">Lotto</a>
</li>
<li class="nav-item active">
<a class="nav-link" href="./rps.html">Rock-Paper-Scissors<span class="sr-only">(current)</span></a>
</li>
</ul>
<div class="navbar-brand" id="time">
</div>
</div>
</nav>
</header>
<main>
<div class="container">
<div class="album py-5 bg-light">
<div class="container">
<div class="row">
<div class="col-md-4">
<div class="card mb-4 box-shadow">
<div id="img1">
<img src="./scissors.jpg">
</div>
<div id="rps1">Rock</div>
</div>
</div>
<div class="col-md-4">
<div class="card mb-4 box-shadow">
<div class="card-body">
<div id="result" class="justify-content-between mt-2"> WIN </div>
<div class="d-flex justify-content-between">
<button
id="rockButton"
type="button"
class="btn btn-md btn-outline-primary"
style="width:33%; font-size:15px"
>ROCK
</button>
<button
id="paperButton"
type="button"
class="btn btn-lg btn-outline-primary"
style="width:33%; font-size:15px"
>PAPER
</button>
<button
id="scissorsButton"
type="button"
class="btn btn-lg btn-outline-primary"
style="width:33%; font-size:13px"
>SCISSORS
</button>
</div>
<div class="d-flex justify-content-between mt-2">
<button
id="reset"
type="button"
class="btn btn-lg btn-block btn-outline-primary"
style= "font-size:15px"
>RESET
</button>
</div>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card mb-4 box-shadow">
<div id="img2">
<img src="./scissors.jpg">
</div>
<div id="rps2">Rock</div>
</div>
</div>
</div>
</main>
<footer>
<div class="bg-dark py-2">
<div class="container text-center">
<p class="text-muted mb-0 py-2">
© 2023 GlobalIn 5 jekeun jang.
</p>
</div>
</div>
</footer>
<script>
setInterval(function () {
var timer = new Date();
var h = timer.getHours();
var m = timer.getMinutes();
var s = timer.getSeconds();
$("#time").html(
"TIME " + String(h).padStart(2,"0") + ":" + String(m).padStart(2,"0") + ":" + String(s).padStart(2,"0"))
}, 1000)
var rock = "<img src=./rock.jpg>"
var paper = "<img src=./paper.jpg>"
var scissors = "<img src=./scissors.jpg>"
var arrRpsp = [rock,paper,scissors]
var arrRps = ["ROCK","PAPER","SCISSORS"]
var interval1 = setInterval(function(){
var randomRps = Math.floor(Math.random()*3);
$("#img2").html(arrRpsp[randomRps])
$("#rps2").text(arrRps[randomRps]);
},50);
var interval2 = setInterval(function(){
var randomRps = Math.floor(Math.random()*3);
$("#img1").html(arrRpsp[randomRps])
$("#rps1").text(arrRps[randomRps]);
},50);
$("#rockButton").click(function(){
clearInterval(interval1);
clearInterval(interval2);
$("#img1").html(arrRpsp[0]);
$("#rps1").text(arrRps[0]);
if($("#rps2").text() == arrRps[0]){
$("#result").text("DRAW");
}else if($("#rps2").text() == arrRps[1]){
$("#result").text("LOSE");
}else{
$("#result").text("WIN");
}
});
$("#paperButton").click(function(){
clearInterval(interval1);
clearInterval(interval2);
$("#img1").html(arrRpsp[1]);
$("#rps1").text(arrRps[1]);
if($("#rps2").text() == arrRps[0]){
$("#result").text("WIN");
}else if($("#rps2").text() == arrRps[1]){
$("#result").text("DRAW");
}else{
$("#result").text("LOSE");
}
});
$("#scissorsButton").click(function(){
clearInterval(interval1);
clearInterval(interval2);
$("#img1").html(arrRpsp[2]);
$("#rps1").text(arrRps[2]);
if($("#rps2").text() == arrRps[0]){
$("#result").text("LOSE");
}else if($("#rps2").text() == arrRps[1]){
$("#result").text("WIN");
}else{
$("#result").text("DRAW");
}
});
$("#reset").click(function(){
interval1 = setInterval(function(){
randomRps = Math.floor(Math.random()*3);
$("#img2").html(arrRpsp[randomRps])
$("#rps2").text(arrRps[randomRps]);
},50);
interval2 = setInterval(function(){
randomRps = Math.floor(Math.random()*3);
$("#img1").html(arrRpsp[randomRps])
$("#rps1").text(arrRps[randomRps]);
},50);
}
)
</script>
</body>
</html>