-
Notifications
You must be signed in to change notification settings - Fork 0
/
menu.js
65 lines (52 loc) · 1.84 KB
/
menu.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
class MenuState {
enter(manager) {
this.manager = manager;
this.manager.params.bgm.play("music-menu");
this.speed = .3;
this.dist = 12;
this.cameraPos = new Vec3(-5, 10, -20);
this.shipPos = new Vec3(0, 2.6, 0);
let shader = this.manager.params.shader;
let shaderCodes = this.manager.params.shaderCodes;
shader.setShaders(shaderCodes.mainVertex, shaderCodes.menuFragmentCode);
let dialog = this.manager.params.dialog;
dialog.showList(["Press SPACE to start", "Let's dive in."], this.startGame.bind(this), null);
this.manager.params.title.classList.remove("hidden");
let that = this;
co(function*() {
let col = 0.0;
while (col < 1.0) {
col += .05;
shader.uniform1f("colorFade", col);
yield .01;
}
shader.uniform1f("colorFade", 1.0);
});
}
startGame() {
let shader = this.manager.params.shader;
let that = this;
this.manager.params.bgm.stop("music-menu");
co(function*() {
let col = 1.0;
while (col > 0.0) {
col -= .08;
shader.uniform1f("colorFade", col);
yield .01;
}
that.manager.params.title.classList.add("hidden");
shader.uniform1f("colorFade", 0.0);
yield 1;
that.manager.setState(new GameplayState());
});
}
update() {
let gl = this.manager.params.gl;
let input = this.manager.params.input;
let shader = this.manager.params.shader;
shader.uniformv("camera_pos", this.cameraPos);
shader.uniformv("ship_pos", this.shipPos);
}
exit() {
}
}