-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtitle.js
More file actions
65 lines (64 loc) · 1.89 KB
/
title.js
File metadata and controls
65 lines (64 loc) · 1.89 KB
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
/* global renderTilemap, gameState:writable, GameStates, titleTilemap, Tilemap, loadTilemap */
const TitleStates = {
TITLE: 0,
INSTRUCTIONS: 1,
};
class Title {
constructor() {
this.instructionsTilemap = new Tilemap();
loadXML("assets/tilemaps/instructions.tmx", (xml) =>
loadTilemap(xml, this.instructionsTilemap),
);
this.titleState = TitleStates.TITLE;
}
loop() {
renderTilemap(titleTilemap);
push();
fill(0);
textSize(100);
textAlign(CENTER, CENTER);
text("STRIKE", width / 2, 66);
textSize(50);
text("Play", width / 2, 232);
text("Instructions", width / 2, 294);
pop();
if (this.titleState === TitleStates.TITLE) {
// Play button
if (
mouseX > 22 * 16 &&
mouseX < 27 * 17 &&
mouseY > 14 * 16 &&
mouseY < 15 * 17
) {
if (mouseIsPressed) {
print(mouseY);
gameState = GameStates.PLAY;
}
}
// Instructions button
if (
mouseX > 18 * 16 &&
mouseX < 31 * 17 &&
mouseY > 18 * 16 &&
mouseY < 19 * 17
) {
if (mouseIsPressed) {
this.titleState = TitleStates.INSTRUCTIONS;
}
}
} else if (this.titleState === TitleStates.INSTRUCTIONS) {
renderTilemap(this.instructionsTilemap);
// Back button
if (
mouseX > 22 * 16 &&
mouseX < 27 * 17 &&
mouseY > 23 * 16 &&
mouseY < 24 * 17
) {
if (mouseIsPressed) {
this.titleState = TitleStates.TITLE;
}
}
}
}
}