-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathapp.js
45 lines (36 loc) · 834 Bytes
/
app.js
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
var holdon = new Audio('holdon.wav');
var coon = new Audio('racoon.wav');
var dead = new Audio('dead.wav');
var adventure = new Adventure(3,3,8,8,8);
//var anotherAdventure = new Adventure(4,2,7,7,7);
function movDown() {
adventure.mov(0, -1, 0, 1, adventure.bound);
};
function movUp() {
adventure.mov(0, 1, 0, -1, 0);
};
function movLeft() {
adventure.mov(1, 0, -1, 0, 0);
};
function movRight() {
adventure.mov(-1, 0, 1, 0, adventure.bound);
};
document.onkeydown = function(e) {
switch (e.keyCode) {
case 37:
movLeft();
break;
case 38:
movUp();
break;
case 39:
movRight();
break;
case 40:
movDown();
break;
case 32:
adventure.reset();
break;
}
};