-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlazur.js
36 lines (32 loc) · 858 Bytes
/
lazur.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
import { VL, CL, poses } from "./elgato.js";
import { Entity } from "./entity.js";
import { SFX } from "./sfx.js";
// Wow. Lazur.
function Lazur(posx, posy, dx, dy) {
SFX.play('shot.mp3');
let pose;
if (dx == 1) {
if (dy == 1) pose = poses.lazer_SE;
else if (dy == -1) pose = poses.lazer_NE;
else pose = poses.lazer_E;
} else if (dx == -1) {
if (dy == 1) pose = poses.lazer_SO;
else if (dy == -1) pose = poses.lazer_NO;
else pose = poses.lazer_O;
} else {
if (dy == 1) pose = poses.lazer_S;
else if (dy == -1) pose = poses.lazer_N;
else {
pose = poses.lazer_E;
dx = 1;
}
}
let o = Entity()
.hasPos(posx, posy)
.hasVel(dx * 8, dy * 8)
.hasSprite(VL.frf, pose, poses.lazer_0)
.hasCollision(CL.frf, () => o.remove())
.hasBoundary(10, 10);
return o;
}
export { Lazur };