-
Notifications
You must be signed in to change notification settings - Fork 1
/
Minigame.cpp
126 lines (116 loc) · 3.32 KB
/
Minigame.cpp
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
120
121
122
123
124
125
126
#include "Minigame.h"
Minigame::Minigame() {
shootingGallery = NULL;
watermelonSmash = NULL;
karaoke = NULL;
shop = NULL;
}
Minigame::~Minigame() {
if (shootingGallery != NULL)
delete shootingGallery;
if (watermelonSmash != NULL)
delete watermelonSmash;
if (karaoke != NULL)
delete karaoke;
if (shop != NULL)
delete shop;
}
void Minigame::step(Window* window) {
if (shootingGallery != NULL)
shootingGallery->step(window);
if (watermelonSmash != NULL)
watermelonSmash->step(window);
if (karaoke != NULL)
karaoke->step(window);
if (shop != NULL)
shop->step(window);
}
void Minigame::mouseClick(glm::vec3 direction, glm::vec4 point) {
if (shootingGallery != NULL)
shootingGallery->mouseClick(direction, point);
if (watermelonSmash != NULL)
watermelonSmash->mouseClick(direction, point);
}
void Minigame::mouseMove(double xpos, double ypos, int width, int height) {
if (shootingGallery != NULL)
shootingGallery->mouseMove(xpos, ypos, width, height);
}
void Minigame::arrowPress(int key) {
if (karaoke != NULL) {
// still choosing a karaoke song
if (!karaoke->songChosen) {
if (key == GLFW_KEY_UP)
karaoke->increaseDifficulty();
else if (key == GLFW_KEY_DOWN)
karaoke->decreaseDifficulty();
else if (key == GLFW_KEY_LEFT)
karaoke->prevSong();
else if (key == GLFW_KEY_RIGHT)
karaoke->nextSong();
}
// selecting an arrow
else if (!karaoke->gameOver) {
if (key == GLFW_KEY_UP)
karaoke->selectCharacter(1);
else if (key == GLFW_KEY_DOWN)
karaoke->selectCharacter(2);
else if (key == GLFW_KEY_LEFT)
karaoke->selectCharacter(0);
else if (key == GLFW_KEY_RIGHT)
karaoke->selectCharacter(3);
}
}
if (shop != NULL) {
if (key == GLFW_KEY_LEFT)
shop->prevItem();
else if (key == GLFW_KEY_RIGHT)
shop->nextItem();
}
if (shootingGallery != NULL) {
if (key == GLFW_KEY_UP)
shootingGallery->changeDifficulty(1);
else if (key == GLFW_KEY_DOWN)
shootingGallery->changeDifficulty(-1);
}
}
void Minigame::setGameStart(bool _gameStart) {
if (shootingGallery != NULL)
shootingGallery->gameStart = _gameStart;
if (watermelonSmash != NULL)
watermelonSmash->gameStart = _gameStart;
if (karaoke != NULL)
karaoke->selectSong();
if (shop != NULL) {
if (!shop->gameStart)
shop->gameStart = _gameStart;
else
shop->selectItem();
}
}
bool Minigame::getGameOver() {
if (shootingGallery != NULL)
return shootingGallery->gameOver;
if (watermelonSmash != NULL)
return watermelonSmash->gameOver;
if (karaoke != NULL)
return karaoke->gameOver;
return false;
}
void Minigame::clearMinigames() {
if (shootingGallery != NULL) {
delete shootingGallery;
shootingGallery = NULL;
}
if (watermelonSmash != NULL) {
delete watermelonSmash;
watermelonSmash = NULL;
}
if (karaoke != NULL) {
delete karaoke;
karaoke = NULL;
}
if (shop != NULL) {
delete shop;
shop = NULL;
}
}