forked from Kos/js13k-2021
-
Notifications
You must be signed in to change notification settings - Fork 1
/
hacks.ts
53 lines (50 loc) · 1016 Bytes
/
hacks.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
// Hacks - remove later
import { makeExplosion, particles } from "./particles";
import { boom, newAsteroid, setLevel, state, titleScreen } from "./state";
window.addEventListener("keypress", (e) => {
if (e.key === "a") {
newAsteroid();
}
if (e.key === "A") {
state.asteroids = [];
}
if (e.key === "P") {
particles.push(...makeExplosion([-3, 4]));
}
if (e.key === "T") {
titleScreen();
}
if (e.code === "Digit1") {
state.signs = [];
setLevel(0);
}
if (e.code === "Digit2") {
state.signs = [];
setLevel(1);
}
if (e.code === "Digit3") {
state.signs = [];
setLevel(2);
}
if (e.code === "Digit4") {
state.signs = [];
setLevel(3);
}
if (e.code === "Digit5") {
state.signs = [];
setLevel(4);
}
if (e.code === "Digit6") {
state.signs = [];
setLevel(5);
}
if (e.key === "L") {
state.powerups.push({
pos: [0, 0],
vec: [0.1, 0.1],
});
}
});
if (state.asteroids.length === 0) {
newAsteroid();
}