-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
269 lines (192 loc) · 9.16 KB
/
index.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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
<!DOCTYPE html>
<html>
<head>
<title>ROBOT SUMO BATTLE SIMULATOR</title>
<meta charset="UTF-8" />
<link href="https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css" rel="stylesheet">
<link href="side-panels.css" rel="stylesheet">
<link href="gh-fork-ribbon.css" rel="stylesheet">
<link rel="canonical" href="https://santiherranz.github.io/SumoFighters/" />
<!-- Primary Meta Tags -->
<meta name="title" content="Javascript Sumo Robot Battle Simulator | Santi Herranz">
<meta name="description" content="Javascript Simulator for testing robot strategies in sumo battle.">
<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image">
<meta property="twitter:url" content="https://santiherranz.github.io/SumoFighters/">
<meta property="twitter:title" content="Javascript Sumo Robot Battle Simulator | Santi Herranz">
<meta name="twitter:creator" content="@santiherranz">
<meta property="twitter:description" content="Javascript Simulator for testing robot strategies in sumo battle">
<meta property="twitter:image" content="https://santiherranz.github.io/SumoFighters/screenshot.png">
<meta name="author" content="santiHerranz">
<meta name="robots" content="index, follow">
<style>
body {
margin: 0;
overflow: hidden;
background: black;
}
</style>
</head>
<body>
<!-- <div class="fixed w-full text-white" style="display:flex; align-items:center; justify-content:center;">
</div> -->
<div class="fixed w-full bg-gray-600 p-2 text-white " style="display:flex; align-items:center; justify-content:center; ">
<div class="absolute left-0 top-0">
<span style="font-size:24px;cursor:pointer;" onclick="openLeftNav()">☰ <span
class="bg-blue-600 p-2 rounded-md">Robot A</span></span>
</div>
<div class="text-lg px-4">Score: <span id="scoreAEl" class="bg-blue-600 p-2 rounded-lg"></span> - <span id="scoreBEl" class="bg-red-600 p-2 rounded-lg"></span> </div>
<div class="px-4">
<button class="button bg-green-600 w-20 h-10 rounded-md p-0" id="gamePauseBtn">Pause</button>
</div>
<div class="px-4">
Time speed:<input id=slider_masterTimeSpeed title='time' type=range min=1 max=50 value=12 style=width:200px
oninput=UpdateSettings();>
</div>
<div class="px-4">
<input type=checkbox id=input_showrays onchange="UpdateSettings();"> <label for="input_showrays"> Show Rays
</label>
</div>
<div class="px-4">
<input type=checkbox id=input_showtrails checked onchange="UpdateSettings();"> <label for="input_showtrails"> Show Trails
</label>
</div>
<div class="px-4">
<input type=checkbox id=input_playsounds checked onchange="UpdateSettings();"> <label for="input_playsounds"> Play sounds
</label>
</div>
<div class="px-4 hidden">
<input type=checkbox id=input_playcollision_sounds checked onchange="UpdateSettings();"> <label for="input_playcollision_sounds"> Play collision sound
</label>
</div>
<div class="absolute top-0 right-0">
<span style="font-size:24px;cursor:pointer;" onclick="openRightNav()"><span
class="bg-red-600 p-2 rounded-lg">Robot B</span> ☰</span>
</div>
</div>
<div id="myLeftNav" class="overlay-left">
<a href="javascript:void(0)" class="closebtn" onclick="closeLeftNav()">×</a>
<div class="overlay-left-content">
<a href="#"><span class="bg-blue-600 p-2 rounded-lg">ROBOT A</span></a>
<div>
<h2><span class="text-white p-2 rounded-lg">Status</span></h2>
<textarea id="statusAText" rows="5" cols="60" class="text-grey-darkest flex-1 p-2 m-1 text-xs"
style="float:left; width: 100%;"></textarea>
<h2><span class="text-white p-2 rounded-lg">Strategy</span></h2>
<textarea id="strategyAFuncText" rows="25" cols="60" class="text-grey-darkest flex-1 p-2 m-1 text-xs"
style="float:left; width: 100%;"></textarea>
</div>
</div>
</div>
<div id="myRightNav" class="overlay-right">
<a href="javascript:void(0)" class="closebtn" onclick="closeRightNav()">×</a>
<div class="overlay-right-content">
<a href="#"><span class="bg-red-600 p-2 rounded-lg">ROBOT B</span></a>
<div>
<h2><span class="text-white p-2 rounded-lg">Status</span></h2>
<textarea id="statusBText" rows="5" cols="60" class="text-grey-darkest flex-1 p-2 m-1 text-xs"
style="float:right; width: 100%;"></textarea>
<h2><span class="text-white p-2 rounded-lg">Strategy</span></h2>
<textarea id="strategyBFuncText" rows="50" cols="60" class="text-grey-darkest flex-1 p-2 m-1 text-xs"
style="float:right; width: 100%;"></textarea>
</div>
</div>
</div>
<div class="fixed inset-0 bg-gray-900 bg-opacity-50 overflow-y-auto h-full w-full" id="my-modal"></div>
<div class="fixed inset-0 flex items-center justify-center rounded-lg" id="menuGame">
<div class="bg-white border-gray-300 max-w-md w-full p-6 space-y-10 text-center rounded-lg">
<h1 class="text-4xl font-bold leading-none p-8 text-black">
ROBOT SUMO BATTLE
</h1>
<div>
<button class="button bg-blue-600 text-white w-full py-3 rounded-full" id="btnCPUvsCPU">Computer vs
Computer</button>
</div>
<div>
<button class="button bg-green-600 text-white w-full py-3 rounded-full" id="btnPlayervsCPU">Player vs
Computer</button>
</div>
</div>
</div>
<div class="fixed inset-0 flex items-center justify-center rounded-lg" id="modalEl">
<div class="bg-white border-gray-300 max-w-md w-full p-6 text-center rounded-lg">
<h1 class="text-4xl font-bold leading-none p-8 text-white">
<span class="relative inline-flex rounded-md shadow-sm">
<span class="bg-blue-600 p-4 rounded-lg" id="scoreABigEl"></span>
<span id="yukoScoreA" class="flex absolute h-5 w-5 top-0 right-0 -mt-1 -mr-1">
<span class="animate-ping absolute inline-flex h-full w-full rounded-full bg-orange-400 opacity-75"></span>
<span class="relative inline-flex rounded-full h-5 w-5 bg-yellow-500"></span>
</span>
</span>
<span class="text-black"> vs</span>
<span class="relative inline-flex rounded-md shadow-sm">
<span class="bg-red-600 p-4 rounded-lg" id="scoreBBigEl"></span>
<span id="yukoScoreB" class="flex absolute h-5 w-5 top-0 right-0 -mt-1 -mr-1">
<span class="animate-ping absolute inline-flex h-full w-full rounded-full bg-orange-400 opacity-75"></span>
<span class="relative inline-flex rounded-full h-5 w-5 bg-yellow-500"></span>
</span>
</span>
</h1>
<p class="text-sm text-gray-700 mb-4">Points</p>
<div class="space-y-10">
<div>
<button class="button bg-blue-600 text-white w-full py-3 rounded-full" id="gameBtn">Start game</button>
</div>
<div>
<button class="button bg-green-600 text-white w-full py-3 rounded-full" id="menuBackBtn">Back to
menu</button>
</div>
</div>
</div>
</div>
<canvas id="canvas"></canvas>
<a class="github-fork-ribbon left-bottom fixed" href="https://github.com/santiHerranz/SumoFighters"
data-ribbon="Fork me on GitHub" title="Fork me on GitHub">Fork me on GitHub</a>
<script>
function openLeftNav() {
document.getElementById("myLeftNav").style.width = "20%";
}
function closeLeftNav() {
document.getElementById("myLeftNav").style.width = "0%";
}
function openRightNav() {
document.getElementById("myRightNav").style.width = "20%";
document.getElementById("myRightNav").style.right = "0px";
}
function closeRightNav() {
document.getElementById("myRightNav").style.width = "0%";
}
</script>
<script>
function UpdateSettings() {
const v = slider_masterTimeSpeed.value;
deltaTime = v / 100;
showRays = input_showrays.checked;
showTrails = input_showtrails.checked;
playSounds = input_playsounds.checked;
input_playcollision_sounds.disabled = !input_playsounds.checked;
playCollisionSound = input_playcollision_sounds.checked && !input_playcollision_sounds.disabled;
}
</script>
<script src="scripts/ZzFXMicro.min.js"></script>
<script src="scripts/sounds.js"></script>
<script src="scripts/vector.js"></script>
<script src="scripts/ray.js"></script>
<script src="scripts/boundary.js"></script>
<script src="scripts/inputs.js"></script>
<script src="scripts/trail.js"></script>
<script src="scripts/particle.js"></script>
<script src="scripts/dojo.js"></script>
<script src="scripts/strategy.js"></script>
<script src="scripts/strategy-attack.js"></script>
<script src="scripts/strategy-attack-state.js"></script>
<script src="scripts/strategy-defend.js"></script>
<script src="scripts/strategy-evade.js"></script>
<script src="scripts/strategy-seek.js"></script>
<script src="scripts/strategy-keepinside.js"></script>
<script src="scripts/strategy-sidemoves.js"></script>
<script src="scripts/player.js"></script>
<script src="scripts/game.js"></script>
<script src="scripts/app.js"></script>
</body>
</html>