-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStatus.hpp
119 lines (106 loc) · 3.51 KB
/
Status.hpp
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
void drawlivesandlevel() {
for (int i = 0; i < lives; i++) { // Draw lives
// ((WIDTH - LIFE_SIZE - (lives-1) * LIFE_SPACING) / 2) + LIFE_SPACING * i)
Sprites::drawOverwrite((WIDTH - LIFE_SIZE) / 2 - (lives - 1) * (LIFE_SPACING / 2) + LIFE_SPACING * i, (HEIGHT - LIFE_SIZE) / 2, Life, 0);
}
setcursor((WIDTH - (GetNumberOfDigits(stage.num) + 7) * CHAR_WIDTH)/2, HEIGHT / 4 * 3 - CHAR_HEIGHT / 2);
squidprint("LEVEL: ");
squidprint(stage.num);
}
void drawpoints() {
setcursor(WIDTH / 2 - 24 - (GetNumberOfDigits(stagebonus) + 1) * CHAR_WIDTH / 2, HEIGHT / 2 - CHAR_HEIGHT / 2);
squidprint("+");
squidprint(stagebonus);
setcursor(WIDTH / 2 + 24 - (GetNumberOfDigits(timebonus) + 1) * CHAR_WIDTH / 2, HEIGHT / 2 - CHAR_HEIGHT / 2);
squidprint("+");
squidprint(timebonus);
setcursor((WIDTH - CHAR_WIDTH * (7 + GetNumberOfDigits(score))) / 2, HEIGHT / 4 * 3 - CHAR_HEIGHT / 2);
squidprint("SCORE: ");
scoresquidprint(score);
}
void drawhighscore() {
setcursor((WIDTH - CHAR_WIDTH * (7 + GetNumberOfDigits(score))) / 2, HEIGHT / 2 - CHAR_HEIGHT / 2);
squidprint("SCORE: ");
scoresquidprint(score);
setcursor((WIDTH - CHAR_WIDTH * (9 + GetNumberOfDigits(topscore))) / 2, HEIGHT / 4 * 3 - CHAR_HEIGHT / 2);
squidprint("HISCORE: ");
scoresquidprint(topscore);
}
void setupstatus(int event) {
if (event == GAMEOVER || event == CONGRATS) {
proceedwithA = true;
} else {
proceedwithA = false;
}
status = event;
statustimer = 180;
statustimermax = 180;
gamestate = GAME_STATUS;
}
void gamestatus() {
if (status == MISS) {
if (led) {
arduboy.digitalWriteRGB(RGB_ON, RGB_OFF, RGB_OFF);
}
setcursor(WIDTH / 2 - 2 * CHAR_WIDTH, HEIGHT / 4 - CHAR_HEIGHT / 2);
squidprint("MISS");
} else if (status == GOAL) {
if (led) {
arduboy.digitalWriteRGB(RGB_OFF, RGB_ON, RGB_OFF);
}
setcursor(WIDTH / 2 - 2 * CHAR_WIDTH, HEIGHT / 4 - CHAR_HEIGHT / 2);
squidprint("GOAL");
} else if (status == START) {
if (led) {
arduboy.digitalWriteRGB(RGB_OFF, RGB_ON, RGB_OFF);
}
setcursor(WIDTH / 2 - 3 * CHAR_WIDTH, HEIGHT / 4 - CHAR_HEIGHT / 2);
squidprint("START!");
} else if (status == GAMEOVER) {
if (led) {
arduboy.digitalWriteRGB(RGB_ON, RGB_OFF, RGB_ON);
}
setcursor(WIDTH / 2 - 5 * CHAR_WIDTH, HEIGHT / 4 - CHAR_HEIGHT / 2);
squidprint("GAME OVER!");
} else if (status == CONGRATS) {
if (led) {
arduboy.digitalWriteRGB(RGB_ON, RGB_ON, RGB_OFF);
}
setcursor(WIDTH / 2 - 8 * CHAR_WIDTH, HEIGHT / 4 - CHAR_HEIGHT / 2);
squidprint("CONGRATULATIONS!");
}
if (statustimer > statustimermax / 2) { // 1st half
if (status == START || status == MISS) {
drawlivesandlevel();
} else if (status == GOAL) {
drawpoints();
} else if (status == CONGRATS) {
drawpoints();
} else if (status == GAMEOVER) {
drawhighscore();
}
} else { // 2nd half
if (status == START || status == MISS || status == GOAL) {
drawlivesandlevel();
} else if (status == GAMEOVER || status == CONGRATS) {
drawhighscore();
}
}
// if (arduboy.justPressed(A_BUTTON)) { // Just for testing?
// statustimer = 0;
// }
if (proceedwithA) {
if (arduboy.justPressed(A_BUTTON)) {
arduboy.digitalWriteRGB(RGB_OFF, RGB_OFF, RGB_OFF);
gamestate = GAME_TITLE;
}
} else if (statustimer <= 0) {
arduboy.digitalWriteRGB(RGB_OFF, RGB_OFF, RGB_OFF);
if (stage.num <= 25) {
gamestate = GAME_PLAY;
}
}
if (statustimer > 0) {
statustimer--;
}
}