-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathindex.ts
55 lines (50 loc) · 1.23 KB
/
index.ts
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
import { PacManState, PacManRenderer } from './pacman-preview/PacManRenderer';
const previewRenderer = new PacManRenderer();
const testState: PacManState = {
pacman: [0, 0, 'down'],
blinky: [1, 0, 'up'],
pinky: [2, 0, 'left'],
inky: [3, 0, 'right'],
clyde: [4, 0, 'up'],
map: [5, 6, [
[1, 1, 1, 1, 1],
[1, 0, 2, 0, 1],
[1, 1, 2, 0, 1],
[1, 0, 2, 2, 1],
[1, 0, 0, 3, 0],
[1, 1, 2, 2, 0]
]],
lives: 3,
points: 10,
level: 1,
ballCount: 6,
ghostCount: {
total: 4,
blinkyCount: 1,
pinkyCount: 2,
inkyCount: 0,
clydeCount: 1
},
state: 'regular',
superTime: 0
};
previewRenderer.loadAssets().then(() => {
previewRenderer.render(testState);
window.addEventListener('keydown', event => {
if (event.key == ' ') {
// space
previewRenderer.render(testState);
} else if (event.keyCode == 38) {
// up arrow
}
else if (event.keyCode == 40) {
// down arrow
}
else if (event.keyCode == 37) {
// left arrow
}
else if (event.keyCode == 39) {
// right arrow
}
});
});