-
Notifications
You must be signed in to change notification settings - Fork 0
/
MAL.cpp
208 lines (188 loc) · 4.49 KB
/
MAL.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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
#include "MAL.h"
int testChoice = 0;
int screen;
const int HOME = 1, TEST_MENU = 2, CHOOSE_ALGORITHM = 3, LCT = 4, SPIRAL = 5, FOREST = 6, SEGMENTS = 7, LIMBO = 15;
bool isTest = false;
/**
* Calls homeScreen() function, then allows user to choose drawing algorithm, then runs it
*
* @param RenderWindow the active game window
*/
void MIDI_art_lab::run(RenderWindow &window) {
bool running = false;
running = true;
screen = HOME;
while (running) {
homeScreen();
while (screen >= HOME) {
while (algorithm == NONE && isTest) {
testChoice = 0;
testChoice = testMenu(window);
if (testChoice > 1) {
//test.run(window, width, height, testChoice);
}
}
testChoice = 0;
algorithm = chooseAlgorithm(window);
switch (algorithm) {
case LCT:
screen = LCT;
//linearCircleTest.run(window, width, height);
break;
case SPIRAL:
std::cout << "\nSTARTING SPIRAL\n\n";
screen = SPIRAL;
spiral.run(window, width, height);
window.clear();
window.display();
break;
case FOREST:
std::cout << "\nSTARTING FOREST\n\n";
screen = FOREST;
forest.run(window, width, height);
window.clear();
window.display();
break;
case SEGMENTS:
std::cout << "\nSTARTING SEGMENTS\n\n";
screen = SEGMENTS;
segments.run(window);
window.clear();
window.display();
break;
default:
break;
}
} //while screen >= HOME
} //while running
}
/**
* Loads home screen (unfinished)
*/
void MIDI_art_lab::homeScreen() {
screen = HOME;
static bool connectionValid = false;
}
/**
* Displays menu prompting user to choose one of four project tests or go to the choose algorithm menu
*
* @param RenderWindow the active game window
* @return user menu choice
*/
int MIDI_art_lab::testMenu(RenderWindow &window) {
screen = TEST_MENU;
int choice = NONE;;
/*
1. Choose Algorithm
2. MIDI Controller Bounds Test
3. MIDI Byte Integrity
4. Framerate Test
5. Correctly Place in Algorithm
*/
Event event;
Texture menuTex;
menuTex.loadFromFile("Images/menu.png");
Sprite menuSprite(menuTex);
menuSprite.setPosition(350.f, 150.f);
window.clear();
window.draw(menuSprite);
window.display();
while (choice == NONE) {
while (window.pollEvent(event))
{
if (event.type == sf::Event::KeyPressed) {
if (Keyboard::isKeyPressed(Keyboard::Num1)) {
choice = 1;
algorithm = LIMBO;
}
else if (Keyboard::isKeyPressed(Keyboard::Num2)) {
choice = 2;
}
else if (Keyboard::isKeyPressed(Keyboard::Num3)) {
choice = 3;
}
else if (Keyboard::isKeyPressed(Keyboard::Num4)) {
choice = 4;
}
else if (Keyboard::isKeyPressed(Keyboard::Num5)) {
choice = 5;
}
}
if (event.type == sf::Event::Closed)
window.close();
}
}
if (choice == 2 || choice == 3) {
Texture consoleTex;
consoleTex.loadFromFile("Images/console.png");
Sprite consoleSprite(consoleTex);
consoleSprite.setPosition(400.f, 150.f);
window.clear();
window.draw(consoleSprite);
window.display();
}
else if (choice == 4 || choice == 5) {
window.clear();
window.display();
}
return choice;
}
/**
* Returns user's choice of algorithm as an int
* user clicks on algorithm of choice
*
* @return int choice
*/
int MIDI_art_lab::chooseAlgorithm(RenderWindow &window) {
screen = CHOOSE_ALGORITHM;
int choice = NONE;;
Event event;
Texture algoChooseTex;
algoChooseTex.loadFromFile("Images/algoChoose.png");
Sprite algoChooseSprite(algoChooseTex);
algoChooseSprite.setPosition(350.f, 150.f);
window.clear();
window.draw(algoChooseSprite);
window.display();
while (choice == NONE) {
while (window.pollEvent(event))
{
if (event.type == sf::Event::KeyPressed) {
if (Keyboard::isKeyPressed(Keyboard::Num1)) {
choice = SPIRAL;
algorithm = SPIRAL;
}
else if (Keyboard::isKeyPressed(Keyboard::Num2)) {
choice = SEGMENTS;
algorithm = SEGMENTS;
}
else if (Keyboard::isKeyPressed(Keyboard::Num3)) {
choice = FOREST;
algorithm = FOREST;
}
}
if (event.type == sf::Event::Closed)
window.close();
}
}
screen = choice;
Texture spaceTex;
spaceTex.loadFromFile("Images/space.png");
Sprite spaceSprite(spaceTex);
spaceSprite.setPosition(350.f, 150.f);
window.clear();
window.draw(spaceSprite);
window.display();
bool ready = false;
while (!ready) {
while (window.pollEvent(event))
{
if (event.type == sf::Event::KeyPressed) {
if (Keyboard::isKeyPressed(Keyboard::Space)) {
ready = true;
}
}
}
}
return choice;
}