-
Notifications
You must be signed in to change notification settings - Fork 5
/
inputHandler.js
66 lines (60 loc) · 1.55 KB
/
inputHandler.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
$(document).keydown((event) => {
var key = event.which;
if(key == LEFT)
{
direction[0] = true;
}
else if(key == RIGHT)
{
direction[3] = true;
}
if(key == SPACE || key == UP)
{
direction[1] = true;
}
else if(key == DOWN)
{
direction[2] = true;
}
});
Mousetrap.bind('g', () => {
grayscale = !grayscale;
});
Mousetrap.bind('f', () => {
flash = true;
setTimeout(() => {
flash = false;
setTimeout(() => {
flash = true;
setTimeout(() => {
flash = false;
setTimeout(() => {
flash = true;
setTimeout(() => {
flash = false;
setTimeout(() => {
flash = true;
setTimeout(() => {
flash = false;
setTimeout(() => {
flash = true;
setTimeout(() => {
flash = false;
}, 500);
}, 500);
}, 500);
}, 500);
}, 500);
}, 500);
}, 500);
}, 500);
}, 500);
});
Mousetrap.bind('p', () => {
PAUSE = !PAUSE;
displayMessage('GAME PAUSED');
});
Mousetrap.bind('q', () => {
GAME = false;
displayMessage('YOU QUIT');
});