-
Notifications
You must be signed in to change notification settings - Fork 0
/
HomeState.h
58 lines (42 loc) · 1.44 KB
/
HomeState.h
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
#include "Global.h"
// -------------------------------------------------------------------------
// Home state
// -------------------------------------------------------------------------
class HomeState {
public:
void update() {
if ((gb.buttons.released(BUTTON_A)) || (gb.buttons.released(BUTTON_B))) {
HomeState::initGame();
}
}
// -------------------------------------------------------------------------
// Initialization of the game
// -------------------------------------------------------------------------
void initGame() {
gb.lights.fill(BLACK);
gameState = GameState::run;
gb.sound.playTick();
misses = 0;
score = 0;
player.spriteIndex = 0;
spawnDelay = 4; // Delay before next possibility to launch a para
sharkAnimation = -2;
floodedAnimation = -2;
speedMax = 25; // Number of cycles before update
helicopterAnimation = 0;
player.spriteIndex = 0;
speedBlades = 5;
moveTick = speedMax;
spawnCount = spawnDelay;
parachuteLaunchCount = 0;
for (auto &value : parachutes)
value = -1;
}
// -------------------------------------------------------------------------
// Draw Titlescreen
// -------------------------------------------------------------------------
void draw() {
drawBackground(splachScreen, spriteGameOver, 0, 0, false);
}
};
HomeState homeState;