-
Notifications
You must be signed in to change notification settings - Fork 2
/
game.html
433 lines (370 loc) Β· 20.2 KB
/
game.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
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Whoofus? | Game</title>
<link rel="icon" type="image/png" href="images/icons/favicon.png"/>
<link href="https://unpkg.com/tailwindcss@^2/dist/tailwind.min.css" rel="stylesheet">
<style>
.modal {
transition: opacity 0.25s ease;
}
body.modal-active {
overflow-x: hidden;
overflow-y: visible !important;
}
.preloader {
position: absolute;
top: 0;
left: 0;
bottom:0;
right:0;
width: 100%;
height: 100vh;
z-index: 99999999;
background-image: url('/assets/loader.gif'); /* your icon gif file path */
background-repeat: no-repeat;
background-color: #FFF;
background-position: center;
}
</style>
<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-K268NLF');</script>
<!-- End Google Tag Manager -->
</head>
<body class="bg-indigo-600 flex items-center justify-center h-screen">
<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-K268NLF"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->
<div class="preloader"></div>
<!--Modal-->
<div id="modal" class="modal opacity-0 pointer-events-none fixed w-full h-full top-0 left-0 flex items-center justify-center">
<div class="modal-overlay absolute w-full h-full bg-gray-900 opacity-50"></div>
<div class="modal-container bg-white w-11/12 md:max-w-md mx-auto rounded shadow-lg z-50 overflow-y-auto">
<!-- <div class="modal-close absolute top-0 right-0 cursor-pointer flex flex-col items-center mt-4 mr-4 text-white text-sm z-50">
<svg class="fill-current text-white" xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 18 18">
<path d="M14.53 4.53l-1.06-1.06L9 7.94 4.53 3.47 3.47 4.53 7.94 9l-4.47 4.47 1.06 1.06L9 10.06l4.47 4.47 1.06-1.06L10.06 9z"></path>
</svg>
<span class="text-sm">(Esc)</span>
</div> -->
<!-- Add margin if you want to see some of the overlay behind the modal-->
<div class="relative modal-content py-4 text-left px-6">
<!--Title-->
<div class="flex justify-between items-center pb-3">
<p v-if="won" class="text-2xl font-bold">Caught The Murderer!</p>
<p v-else-if="lost" class="text-2xl font-bold">Oops, Murderer Ran!</p>
<p v-else-if="gameOver" class="text-2xl font-bold">Game Over! β </p>
<p v-else class="text-2xl font-bold">Who Did It?!</p>
<!-- <div class="modal-close cursor-pointer z-50">
<svg class="fill-current text-black" xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 18 18">
<path d="M14.53 4.53l-1.06-1.06L9 7.94 4.53 3.47 3.47 4.53 7.94 9l-4.47 4.47 1.06 1.06L9 10.06l4.47 4.47 1.06-1.06L10.06 9z"></path>
</svg>
</div> -->
</div>
<img v-if="!gameOver" class="absolute top-4 right-4 h-20" :src="'/characters/' + killed + '/dead.png'" />
<!--Body-->
<p v-if="won" class="mb-5">{{ name(killed) }} was found dead.<br/> {{ name(killer) }} was the murderer.</p>
<p v-else-if="lost" class="mb-5">{{ name(killed) }} was found dead.<br/> {{ name(killer) }} was the murderer.</p>
<p v-else-if="gameOver" class="mb-5">Everyone but the murderer are dead.<br/>You should retry this game.</p>
<p v-else class="mb-5">{{ name(killed) }} was found dead.<br/> Who do you think did it?</p>
<div v-if="won" class="flex w-full mb-2">
<img class="mr-4 h-20" src="/assets/winner.png" />
<div>
<div>Congratulations! π You won!</div>
<div class="text-sm pt-2">You have been a great detective π. Being an amateur detective takes more than wearing a trench coat and fedora. You've got the skills β‘</div>
</div>
</div>
<div v-else-if="lost" class="flex w-full mb-2">
<img class="mr-4 h-20" src="/assets/sadface.png" />
<div>
<div>Oops! π You lost!</div>
<div class="text-sm pt-2">Being a detective π is difficult. It takes skills which let you accurately estimate everyone's moves. You should be always one step before them β‘</div>
</div>
</div>
<div v-else-if="gameOver"></div>
<ul v-else class="w-full mb-2">
<li class="py-2 px-4 rounded mb-1 cursor-pointer" @click="optionSelected(option)" :style="{'backgroundColor': color(option)}" v-for="option of options">{{ name(option) }}</li>
</ul>
<!--Footer-->
<div class="flex justify-end pt-2">
<button v-if="lost" @click="playAgain" class="px-4 bg-transparent py-2 rounded-lg text-indigo-500 hover:bg-gray-100 hover:text-indigo-400 mr-2">Restart</button>
<button v-if="won" @click="playAgain" class="modal-close px-4 bg-indigo-500 py-2 rounded-lg text-white hover:bg-indigo-400">Play Again?</button>
<button v-if="gameOver" @click="playAgain" class="modal-close px-4 bg-indigo-500 py-2 rounded-lg text-white hover:bg-indigo-400">Play Again?</button>
<button v-if="lost" @click="retry" class="modal-close px-4 bg-indigo-500 py-2 rounded-lg text-white hover:bg-indigo-400">Continue?</button>
</div>
</div>
</div>
</div>
<script
src="https://cdnjs.cloudflare.com/ajax/libs/phaser/3.24.1/phaser.min.js"
integrity="sha512-HY/qPTJqpvoNGRufGPn4Tl7duHSam8NfrfTZUHyn5M39oEBcq8p6IeGBE9e+AupikS4Utt+uJhSgG3FYZp/yxA=="
crossorigin="anonymous"
></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vue.js"></script>
<script>
const bodyColors = ["#e5464b", "#5871ea", "#33cb07", "#ebc506", "#940ae3", "#fe06d6", "#10f3e0", "#d3621d"];
const bodyNames = ["Red", "Blue", "Green", "Yellow", "Vio", "Purp", "Teal", "Orange"];
document.addEventListener("DOMContentLoaded", () => {
document.querySelector(".preloader").classList.toggle("hidden");
const modalInstance = new Vue({
el: "#modal",
data: {
options: [],
killed: 0,
killer: 0,
cb: null,
modalOpen: false,
won: false,
lost: false,
gameOver: false,
},
methods: {
toggleModal: function() {
const body = document.querySelector('body')
const modal = document.querySelector('.modal')
modal.classList.toggle('opacity-0')
modal.classList.toggle('pointer-events-none')
body.classList.toggle('modal-active')
this.modal = !this.modal;
},
name: function(i) {
return bodyNames[i];
},
color: function(i) {
return bodyColors[i];
},
optionSelected: function(o) {
if (o === this.killer) {
this.playWon();
} else {
this.playLost();
}
},
playWon: function() {
this.won = true;
console.log("Won!");
},
playLost: function() {
this.lost = true;
console.log("Lost!");
},
retry: function() {
this.lost = false;
this.toggleModal();
this.cb();
},
playAgain: function() {
window.location.reload();
},
makeGameOver: function() {
this.gameOver = true;
this.toggleModal();
}
}
});
function showModal(killed, killer, aliveCharacters, cb) {
// showModal( 0, 1, [2, 3, 4], cb to resume the game)
console.log(killed, killer, aliveCharacters);
modalInstance.options = aliveCharacters;
modalInstance.killed = killed;
modalInstance.killer = killer;
modalInstance.cb = cb;
modalInstance.toggleModal();
}
var map = [
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1],
[ 0, 0, 0, 0, -1, -1, 0, 0, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
[ 0, 0, 0, 0, -1, -1, 0, 0, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
[ 0, 0, 0, 0, -1, -1, 0, 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1],
[ 0, 0, 0, 0, -1, -1, 0, 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1],
[ 0, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
[ 0, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, -1, 0, 0, 0, 0, -1, 0, 0, -1, -1],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, 0, 0, 0, -1, -1, 0, 0, 0, 0, -1, 0, 0, 0, 0, -1, 0, 0, -1, -1],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, 0, 0, 0, -1, -1, 0, 0, 0, 0, -1, -1, -1, -1, -1, -1, 0, 0, -1, -1],
[ 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, 0, 0, 0, -1, -1, 0, 0, 0, 0, -1, 0, 0, 0, 0, -1, 0, 0, -1, -1],
[ 0, 0, -1, -1, -1, 0, 0, 0, 0, 0, 0, -1, -1, 0, 0, 0, -1, -1, 0, 0, 0, 0, -1, 0, 0, 0, 0, -1, 0, 0, -1, -1],
[ 0, 0, 0, 0, -1, -1, -1, -1, 0, 0, 0, -1, -1, 0, 0, 0, -1, -1, 0, 0, 0, 0, -1, 0, 0, 0, 0, -1, 0, 0, -1, -1],
[ 0, 0, -1, -1, -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, 0, 0, -1, -1, 0, 0, 0, 0, -1, 0, 0, 0, 0, -1, 0, 0, -1, -1],
[ 0, 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
[ 0, 0, 0, -1, -1, -1, -1, -1, 0, 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, -1, -1],
[ 0, 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, -1, -1],
[ 0, 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, -1, -1],
[ 0, 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, -1, -1],
[ 0, 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, -1, -1, 0, 0, 0, -1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, -1, -1],
[ 0, 0, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, -1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, -1, -1],
[ 0, 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, -1, -1, 0, 0, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
[ 0, 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, -1, -1, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1],
[ 0, 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, -1, -1, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1],
[ 0, 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, -1, -1, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1],
[ 0, 0, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1],
[ 0, 0, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1],
[ 0, 0, 0, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1],
[ 0, 0, 0, -1, 0, 0, 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1],
[ 0, 0, 0, -1, 0, 0, 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
]
const SIDE = 768;
const CHAR_LIM = 8;
const PROXIMITY = 50;
const LOGIC_EVERY = 4;
const KILL_POSSIBLE_AFTER = 10000;
const mapLocations = [];
for (let i=0; i<map.length; i++) {
for (let j=0; j<map[i].length; j++) {
if (map[i][j] === -1) mapLocations.push({x: i*SIDE/32 + 16, y: j*SIDE/32 + 16, i, j});
}
}
const characters = [];
function getRandomLocation() {
const pos = Math.round(Math.random() * 371)
return {...mapLocations[pos], pos};
}
function getLocation(i, j) {
return {y: i*SIDE/32 + 16, x: j*SIDE/32 + 16, i, j};
}
const procFinished = [];
const killers = {};
var config = {
type: Phaser.WEBGL,
width: SIDE,
height: SIDE,
backgroundColor: "#2d2d2d",
parent: "phaser-example",
pixelArt: true,
scene: {
preload: preload,
create: create,
update: update,
},
};
var controls, startedAt;
let gameRunning = true;
var game = new Phaser.Game(config);
function preload() {
this.load.image("bg", ["assets/map.png", "assets/map-n.png"]);
this.load.image("0-alv", ["characters/0/alive.png", "characters/0/alive-n.png"]);
this.load.image("1-alv", ["characters/1/alive.png", "characters/1/alive-n.png"]);
this.load.image("2-alv", ["characters/2/alive.png", "characters/2/alive-n.png"]);
this.load.image("3-alv", ["characters/3/alive.png", "characters/3/alive-n.png"]);
this.load.image("4-alv", ["characters/4/alive.png", "characters/4/alive-n.png"]);
this.load.image("5-alv", ["characters/5/alive.png", "characters/5/alive-n.png"]);
this.load.image("6-alv", ["characters/6/alive.png", "characters/6/alive-n.png"]);
this.load.image("7-alv", ["characters/7/alive.png", "characters/7/alive-n.png"]);
this.load.image("0-ded", ["characters/0/dead.png", "characters/0/dead-n.png"]);
this.load.image("1-ded", ["characters/1/dead.png", "characters/1/dead-n.png"]);
this.load.image("2-ded", ["characters/2/dead.png", "characters/2/dead-n.png"]);
this.load.image("3-ded", ["characters/3/dead.png", "characters/3/dead-n.png"]);
this.load.image("4-ded", ["characters/4/dead.png", "characters/4/dead-n.png"]);
this.load.image("5-ded", ["characters/5/dead.png", "characters/5/dead-n.png"]);
this.load.image("6-ded", ["characters/6/dead.png", "characters/6/dead-n.png"]);
this.load.image("7-ded", ["characters/7/dead.png", "characters/7/dead-n.png"]);
}
function create() {
var light = this.lights.addLight(0, 0, 200);
this.lights.enable().setAmbientColor(0x000000);
this.input.on("pointermove", function (pointer) {
if (!gameRunning) return;
const X = this.cameras.main.scrollX + pointer.x;
const Y = this.cameras.main.scrollY + pointer.y;
light.x = X;
light.y = Y;
if (characters.length === CHAR_LIM) {
// Initialized and all...
const deads = characters.filter(c=>!c.alive && !procFinished.includes(c.id));
for (let d of deads) {
if (Math.abs(d.l.x - X) <= PROXIMITY && Math.abs(d.l.y - Y) <= PROXIMITY) {
procFinished.push(d.id);
gameRunning = false;
showModal(d.id, killers[d.id], characters.filter(c => c.alive).map(c => c.id), () => {
gameRunning = true;
d.sprite.destroy();
});
}
}
}
});
this.add
.sprite(SIDE / 2, SIDE / 2, "bg")
.setPipeline("Light2D")
.setAlpha(1);
for (let i=0; i<CHAR_LIM; i++) {
const l = getRandomLocation();
const sprite = this.add.sprite(l.y, l.x, `${i}-alv`)
.setScale(0.15)
.setPipeline("Light2D")
.setAlpha(1);
characters.push({sprite, alive: true, l, dir: "x", id: characters.length})
}
startedAt = Date.now();
}
var ran = LOGIC_EVERY;
function isValidLocation(a, b) {
return a>0 && b>0 && a<SIDE && b<SIDE;
}
const pr = (time) => new Promise((resolve) => setTimeout(resolve, time));
async function update(time, delta) {
if (!gameRunning) return;
if (ran !== LOGIC_EVERY) {
ran += 1;
characters.forEach(character => {
if (!character.alive) return;
character.sprite.x += (character.l.x - character.sprite.x)/LOGIC_EVERY;
character.sprite.y += (character.l.y - character.sprite.y)/LOGIC_EVERY;
})
return;
}
characters.forEach((character, index) => {
if (!character.alive) return;
character.sprite.setPosition(character.l.x, character.l.y);
const {i, j} = character.l;
let iKnowLoc = null;
if (character.dir === "w" && isValidLocation(i-1, j) && map[i-1][j] === -1) { iKnowLoc = {i: i-1, j: j}; }
else if (character.dir === "s" && isValidLocation(i+1, j) && map[i+1][j] === -1) { iKnowLoc = {i: i+1, j: j}; }
else if (character.dir === "a" && isValidLocation(i, j-1) && map[i][j-1] === -1) { iKnowLoc = {i: i, j: j-1}; }
else if (character.dir === "d" && isValidLocation(i, j+1) && map[i][j+1] === -1) { iKnowLoc = {i: i, j: j+1}; }
const possibleLocations = [];
for (let p=i-1; p<=i+1; p++) {
for (let q=j-1; q<=j+1; q++) {
if (p<0 || q<0 || p >= SIDE || q >= SIDE) continue;
if (map[p][q] === -1) possibleLocations.push({i: p, j: q});
}
}
let killLoc = null;
if (Date.now() - startedAt >= KILL_POSSIBLE_AFTER){
const charLox = characters.filter((b, z) => b.alive && z !== index).map(c=>({i: c.l.i, j: c.l.j, id: c.id}));
for (let u=0; u<possibleLocations.length; u++) {
const dex = charLox.findIndex(x=>x.i === possibleLocations[u].i && x.j === possibleLocations[u].j);
if (dex != -1 && Math.random() * 800 / CHAR_LIM < 1) {
console.log(characters[index].id, "will kill", characters[charLox[dex].id].id);
killers[characters[charLox[dex].id].id] = characters[index].id;
characters[charLox[dex].id].sprite.setTexture(`${characters[charLox[dex].id].id}-ded`);
characters[charLox[dex].id].alive = false;
killLoc = {i: characters[charLox[dex].id].l.i, j: characters[charLox[dex].id].l.j};
if (charLox.length === 2) {
modalInstance.makeGameOver();
}
}
}
}
const r = Math.floor(Math.random() * possibleLocations.length);
const decidedLocation = killLoc || iKnowLoc || possibleLocations[r];
character.l = getLocation(decidedLocation.i, decidedLocation.j);
// if (i === character.l.i - 1) character.dir = "s";
// else if (i === character.l.i + 1) character.dir = "w";
// else if (j === character.l.j - 1) character.dir = "a";
// else if (j === character.l.j + 1) character.dir = "d";
});
ran = 0;
}
});
</script>
</body>
</html>