Max Houghton
/
MazeGame_el15mh
el15mh 200929957
Menu/Menu.cpp@9:960dfc71c224, 2017-05-04 (annotated)
- Committer:
- el15mh
- Date:
- Thu May 04 14:43:29 2017 +0000
- Revision:
- 9:960dfc71c224
Documented using doxygen
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
el15mh | 9:960dfc71c224 | 1 | #include "Menu.h" |
el15mh | 9:960dfc71c224 | 2 | |
el15mh | 9:960dfc71c224 | 3 | // constructor function used when object is initialised |
el15mh | 9:960dfc71c224 | 4 | Menu::Menu() |
el15mh | 9:960dfc71c224 | 5 | { |
el15mh | 9:960dfc71c224 | 6 | |
el15mh | 9:960dfc71c224 | 7 | } |
el15mh | 9:960dfc71c224 | 8 | |
el15mh | 9:960dfc71c224 | 9 | // destructor function |
el15mh | 9:960dfc71c224 | 10 | Menu::~Menu() |
el15mh | 9:960dfc71c224 | 11 | { |
el15mh | 9:960dfc71c224 | 12 | |
el15mh | 9:960dfc71c224 | 13 | } |
el15mh | 9:960dfc71c224 | 14 | |
el15mh | 9:960dfc71c224 | 15 | /** |
el15mh | 9:960dfc71c224 | 16 | * @details - Initiases the game with default parameters before value specification |
el15mh | 9:960dfc71c224 | 17 | */ |
el15mh | 9:960dfc71c224 | 18 | void Menu::init() |
el15mh | 9:960dfc71c224 | 19 | { |
el15mh | 9:960dfc71c224 | 20 | // set all default game parameters |
el15mh | 9:960dfc71c224 | 21 | _difficulty = 1; |
el15mh | 9:960dfc71c224 | 22 | _FPS = 50; |
el15mh | 9:960dfc71c224 | 23 | |
el15mh | 9:960dfc71c224 | 24 | _control = true; |
el15mh | 9:960dfc71c224 | 25 | _colour = true; |
el15mh | 9:960dfc71c224 | 26 | _tone = true; |
el15mh | 9:960dfc71c224 | 27 | } |
el15mh | 9:960dfc71c224 | 28 | |
el15mh | 9:960dfc71c224 | 29 | /** |
el15mh | 9:960dfc71c224 | 30 | * @details - Main menu function. |
el15mh | 9:960dfc71c224 | 31 | |
el15mh | 9:960dfc71c224 | 32 | */ |
el15mh | 9:960dfc71c224 | 33 | void Menu::main(N5110 &lcd, Gamepad &pad, FXOS8700CQ &device, Animations &animate) |
el15mh | 9:960dfc71c224 | 34 | { |
el15mh | 9:960dfc71c224 | 35 | int selected = 0; |
el15mh | 9:960dfc71c224 | 36 | |
el15mh | 9:960dfc71c224 | 37 | while(1) { |
el15mh | 9:960dfc71c224 | 38 | |
el15mh | 9:960dfc71c224 | 39 | pad.leds_off(); |
el15mh | 9:960dfc71c224 | 40 | |
el15mh | 9:960dfc71c224 | 41 | char d = pad.get_direction(); |
el15mh | 9:960dfc71c224 | 42 | |
el15mh | 9:960dfc71c224 | 43 | if ((d == NW) || |
el15mh | 9:960dfc71c224 | 44 | (d == N) || |
el15mh | 9:960dfc71c224 | 45 | (d == NE)){ |
el15mh | 9:960dfc71c224 | 46 | |
el15mh | 9:960dfc71c224 | 47 | if (_tone){ |
el15mh | 9:960dfc71c224 | 48 | pad.tone(G_NOTE, 0.20); |
el15mh | 9:960dfc71c224 | 49 | } |
el15mh | 9:960dfc71c224 | 50 | selected -= 1; |
el15mh | 9:960dfc71c224 | 51 | } |
el15mh | 9:960dfc71c224 | 52 | |
el15mh | 9:960dfc71c224 | 53 | if ((d == SW) || |
el15mh | 9:960dfc71c224 | 54 | (d == S) || |
el15mh | 9:960dfc71c224 | 55 | (d == SE)){ |
el15mh | 9:960dfc71c224 | 56 | |
el15mh | 9:960dfc71c224 | 57 | if (_tone){ |
el15mh | 9:960dfc71c224 | 58 | pad.tone(G_NOTE, 0.20); |
el15mh | 9:960dfc71c224 | 59 | } |
el15mh | 9:960dfc71c224 | 60 | selected += 1; |
el15mh | 9:960dfc71c224 | 61 | } |
el15mh | 9:960dfc71c224 | 62 | |
el15mh | 9:960dfc71c224 | 63 | // lcd.printString("Testing", 0, 2); |
el15mh | 9:960dfc71c224 | 64 | switch (selected) { |
el15mh | 9:960dfc71c224 | 65 | |
el15mh | 9:960dfc71c224 | 66 | case 1: |
el15mh | 9:960dfc71c224 | 67 | |
el15mh | 9:960dfc71c224 | 68 | lcd.clear(); |
el15mh | 9:960dfc71c224 | 69 | lcd.printString(" ROLLER MAZE ", 0, 0); |
el15mh | 9:960dfc71c224 | 70 | lcd.printString(">Play game", 0, 2); |
el15mh | 9:960dfc71c224 | 71 | lcd.printString(" Game options", 0, 3); |
el15mh | 9:960dfc71c224 | 72 | lcd.printString(" LCD settings", 0, 4); |
el15mh | 9:960dfc71c224 | 73 | lcd.printString(" Sound", 0, 5); |
el15mh | 9:960dfc71c224 | 74 | lcd.refresh(); |
el15mh | 9:960dfc71c224 | 75 | |
el15mh | 9:960dfc71c224 | 76 | // either clicking joystick or pressing A selects function |
el15mh | 9:960dfc71c224 | 77 | if ((pad.check_event(Gamepad::A_PRESSED) || |
el15mh | 9:960dfc71c224 | 78 | pad.check_event(Gamepad::JOY_PRESSED)) || |
el15mh | 9:960dfc71c224 | 79 | (d == E)) { |
el15mh | 9:960dfc71c224 | 80 | |
el15mh | 9:960dfc71c224 | 81 | if (_tone){ |
el15mh | 9:960dfc71c224 | 82 | pad.tone(C_NOTE, 0.20); |
el15mh | 9:960dfc71c224 | 83 | } |
el15mh | 9:960dfc71c224 | 84 | playGame(lcd, pad, device, animate, _difficulty, _tone, _FPS); |
el15mh | 9:960dfc71c224 | 85 | // call the game function |
el15mh | 9:960dfc71c224 | 86 | } |
el15mh | 9:960dfc71c224 | 87 | |
el15mh | 9:960dfc71c224 | 88 | wait_ms(250); // 250ms propogation delay |
el15mh | 9:960dfc71c224 | 89 | |
el15mh | 9:960dfc71c224 | 90 | break; |
el15mh | 9:960dfc71c224 | 91 | |
el15mh | 9:960dfc71c224 | 92 | case 2: |
el15mh | 9:960dfc71c224 | 93 | |
el15mh | 9:960dfc71c224 | 94 | lcd.clear(); |
el15mh | 9:960dfc71c224 | 95 | lcd.printString(" ROLLER MAZE ", 0, 0); |
el15mh | 9:960dfc71c224 | 96 | lcd.printString(" Play game", 0, 2); |
el15mh | 9:960dfc71c224 | 97 | lcd.printString(">Game options", 0, 3); |
el15mh | 9:960dfc71c224 | 98 | lcd.printString(" LCD settings", 0, 4); |
el15mh | 9:960dfc71c224 | 99 | lcd.printString(" Sound", 0, 5); |
el15mh | 9:960dfc71c224 | 100 | lcd.refresh(); |
el15mh | 9:960dfc71c224 | 101 | |
el15mh | 9:960dfc71c224 | 102 | if ((pad.check_event(Gamepad::A_PRESSED) || |
el15mh | 9:960dfc71c224 | 103 | pad.check_event(Gamepad::JOY_PRESSED)) || |
el15mh | 9:960dfc71c224 | 104 | (d == E)) { |
el15mh | 9:960dfc71c224 | 105 | |
el15mh | 9:960dfc71c224 | 106 | if (_tone){ |
el15mh | 9:960dfc71c224 | 107 | pad.tone(C_NOTE, 0.20); |
el15mh | 9:960dfc71c224 | 108 | } |
el15mh | 9:960dfc71c224 | 109 | options(lcd, pad, animate, _tone); |
el15mh | 9:960dfc71c224 | 110 | } |
el15mh | 9:960dfc71c224 | 111 | |
el15mh | 9:960dfc71c224 | 112 | wait_ms(250); // 250ms propogation delay |
el15mh | 9:960dfc71c224 | 113 | |
el15mh | 9:960dfc71c224 | 114 | break; |
el15mh | 9:960dfc71c224 | 115 | |
el15mh | 9:960dfc71c224 | 116 | case 3: |
el15mh | 9:960dfc71c224 | 117 | |
el15mh | 9:960dfc71c224 | 118 | lcd.clear(); |
el15mh | 9:960dfc71c224 | 119 | lcd.printString(" ROLLER MAZE ", 0, 0); |
el15mh | 9:960dfc71c224 | 120 | lcd.printString(" Play game", 0, 2); |
el15mh | 9:960dfc71c224 | 121 | lcd.printString(" Game options", 0, 3); |
el15mh | 9:960dfc71c224 | 122 | lcd.printString(">LCD settings", 0, 4); |
el15mh | 9:960dfc71c224 | 123 | lcd.printString(" Sound", 0, 5); |
el15mh | 9:960dfc71c224 | 124 | lcd.refresh(); |
el15mh | 9:960dfc71c224 | 125 | |
el15mh | 9:960dfc71c224 | 126 | if ((pad.check_event(Gamepad::A_PRESSED) || |
el15mh | 9:960dfc71c224 | 127 | pad.check_event(Gamepad::JOY_PRESSED)) || |
el15mh | 9:960dfc71c224 | 128 | (d == E)) { |
el15mh | 9:960dfc71c224 | 129 | |
el15mh | 9:960dfc71c224 | 130 | if (_tone){ |
el15mh | 9:960dfc71c224 | 131 | pad.tone(C_NOTE, 0.20); |
el15mh | 9:960dfc71c224 | 132 | } |
el15mh | 9:960dfc71c224 | 133 | lcdSettings(lcd, pad, animate); |
el15mh | 9:960dfc71c224 | 134 | } |
el15mh | 9:960dfc71c224 | 135 | |
el15mh | 9:960dfc71c224 | 136 | wait_ms(250); // 250ms propogation delay |
el15mh | 9:960dfc71c224 | 137 | |
el15mh | 9:960dfc71c224 | 138 | break; |
el15mh | 9:960dfc71c224 | 139 | |
el15mh | 9:960dfc71c224 | 140 | case 4: |
el15mh | 9:960dfc71c224 | 141 | |
el15mh | 9:960dfc71c224 | 142 | lcd.clear(); |
el15mh | 9:960dfc71c224 | 143 | lcd.printString(" ROLLER MAZE ", 0, 0); |
el15mh | 9:960dfc71c224 | 144 | lcd.printString(" Play game", 0, 2); |
el15mh | 9:960dfc71c224 | 145 | lcd.printString(" Game options", 0, 3); |
el15mh | 9:960dfc71c224 | 146 | lcd.printString(" LCD settings", 0, 4); |
el15mh | 9:960dfc71c224 | 147 | lcd.printString(">Sound", 0, 5); |
el15mh | 9:960dfc71c224 | 148 | lcd.refresh(); |
el15mh | 9:960dfc71c224 | 149 | |
el15mh | 9:960dfc71c224 | 150 | |
el15mh | 9:960dfc71c224 | 151 | if ((pad.check_event(Gamepad::A_PRESSED) || |
el15mh | 9:960dfc71c224 | 152 | pad.check_event(Gamepad::JOY_PRESSED)) || |
el15mh | 9:960dfc71c224 | 153 | (d == E)) { |
el15mh | 9:960dfc71c224 | 154 | |
el15mh | 9:960dfc71c224 | 155 | if (_tone){ |
el15mh | 9:960dfc71c224 | 156 | pad.tone(C_NOTE, 0.20); |
el15mh | 9:960dfc71c224 | 157 | } |
el15mh | 9:960dfc71c224 | 158 | soundSettings(lcd, pad, animate); |
el15mh | 9:960dfc71c224 | 159 | } |
el15mh | 9:960dfc71c224 | 160 | |
el15mh | 9:960dfc71c224 | 161 | wait_ms(250); // 250ms propogation delay |
el15mh | 9:960dfc71c224 | 162 | |
el15mh | 9:960dfc71c224 | 163 | break; |
el15mh | 9:960dfc71c224 | 164 | |
el15mh | 9:960dfc71c224 | 165 | default: |
el15mh | 9:960dfc71c224 | 166 | |
el15mh | 9:960dfc71c224 | 167 | selected = 1; |
el15mh | 9:960dfc71c224 | 168 | |
el15mh | 9:960dfc71c224 | 169 | break; |
el15mh | 9:960dfc71c224 | 170 | } |
el15mh | 9:960dfc71c224 | 171 | |
el15mh | 9:960dfc71c224 | 172 | // printf("Joystick position = %c \n", d); |
el15mh | 9:960dfc71c224 | 173 | // printf("Selected = %i \n", selected); |
el15mh | 9:960dfc71c224 | 174 | |
el15mh | 9:960dfc71c224 | 175 | } |
el15mh | 9:960dfc71c224 | 176 | } |
el15mh | 9:960dfc71c224 | 177 | |
el15mh | 9:960dfc71c224 | 178 | /** |
el15mh | 9:960dfc71c224 | 179 | * @details - Game introduction function. |
el15mh | 9:960dfc71c224 | 180 | */ |
el15mh | 9:960dfc71c224 | 181 | void Menu::intro(N5110 &lcd, Gamepad &pad, Animations &animate) |
el15mh | 9:960dfc71c224 | 182 | { |
el15mh | 9:960dfc71c224 | 183 | // printf("intro started \n"); |
el15mh | 9:960dfc71c224 | 184 | while (pad.check_event(Gamepad::START_PRESSED) == false){ |
el15mh | 9:960dfc71c224 | 185 | |
el15mh | 9:960dfc71c224 | 186 | animate.intro(lcd, pad); |
el15mh | 9:960dfc71c224 | 187 | } |
el15mh | 9:960dfc71c224 | 188 | } |
el15mh | 9:960dfc71c224 | 189 | |
el15mh | 9:960dfc71c224 | 190 | /** |
el15mh | 9:960dfc71c224 | 191 | * @details - Game Loop function. |
el15mh | 9:960dfc71c224 | 192 | */ |
el15mh | 9:960dfc71c224 | 193 | void Menu::playGame(N5110 &lcd, |
el15mh | 9:960dfc71c224 | 194 | Gamepad &pad, |
el15mh | 9:960dfc71c224 | 195 | FXOS8700CQ &device, |
el15mh | 9:960dfc71c224 | 196 | Animations &animate, |
el15mh | 9:960dfc71c224 | 197 | int difficulty, |
el15mh | 9:960dfc71c224 | 198 | bool tone, |
el15mh | 9:960dfc71c224 | 199 | float FPS) |
el15mh | 9:960dfc71c224 | 200 | { |
el15mh | 9:960dfc71c224 | 201 | int x; |
el15mh | 9:960dfc71c224 | 202 | int y; |
el15mh | 9:960dfc71c224 | 203 | int radius; |
el15mh | 9:960dfc71c224 | 204 | |
el15mh | 9:960dfc71c224 | 205 | _mazeIndex = randomMazeIndexGenerator(_difficulty); |
el15mh | 9:960dfc71c224 | 206 | // generates random number for maze index between different |
el15mh | 9:960dfc71c224 | 207 | // pairs of values with corresponding difficulties |
el15mh | 9:960dfc71c224 | 208 | |
el15mh | 9:960dfc71c224 | 209 | _FPS = 100 - FPS; |
el15mh | 9:960dfc71c224 | 210 | // from game speed fuction (line , low FPS value corresponds to fast gameplay |
el15mh | 9:960dfc71c224 | 211 | // so perform basic inversion (works when value is between 25 - 75) |
el15mh | 9:960dfc71c224 | 212 | |
el15mh | 9:960dfc71c224 | 213 | if (difficulty == 1) { |
el15mh | 9:960dfc71c224 | 214 | |
el15mh | 9:960dfc71c224 | 215 | x = 5; // place ball in appropriate location for each difficulty |
el15mh | 9:960dfc71c224 | 216 | y = 5; |
el15mh | 9:960dfc71c224 | 217 | radius = 2; // set radius accordingly |
el15mh | 9:960dfc71c224 | 218 | } |
el15mh | 9:960dfc71c224 | 219 | |
el15mh | 9:960dfc71c224 | 220 | else if (difficulty == 2){ |
el15mh | 9:960dfc71c224 | 221 | |
el15mh | 9:960dfc71c224 | 222 | x = 3; |
el15mh | 9:960dfc71c224 | 223 | y = 4; |
el15mh | 9:960dfc71c224 | 224 | radius = 1; |
el15mh | 9:960dfc71c224 | 225 | } |
el15mh | 9:960dfc71c224 | 226 | |
el15mh | 9:960dfc71c224 | 227 | else if (difficulty == 3){ |
el15mh | 9:960dfc71c224 | 228 | |
el15mh | 9:960dfc71c224 | 229 | x = 5; |
el15mh | 9:960dfc71c224 | 230 | y = 3; |
el15mh | 9:960dfc71c224 | 231 | radius = 0; |
el15mh | 9:960dfc71c224 | 232 | } |
el15mh | 9:960dfc71c224 | 233 | |
el15mh | 9:960dfc71c224 | 234 | else { |
el15mh | 9:960dfc71c224 | 235 | |
el15mh | 9:960dfc71c224 | 236 | x = 2; |
el15mh | 9:960dfc71c224 | 237 | y = 2; |
el15mh | 9:960dfc71c224 | 238 | radius = 0; |
el15mh | 9:960dfc71c224 | 239 | } |
el15mh | 9:960dfc71c224 | 240 | |
el15mh | 9:960dfc71c224 | 241 | // now initialise game with correct game parameters for chosen difficulty |
el15mh | 9:960dfc71c224 | 242 | |
el15mh | 9:960dfc71c224 | 243 | _engine.init(_mazeIndex, // selects maze difficulty |
el15mh | 9:960dfc71c224 | 244 | x, // defines starting x position for ball |
el15mh | 9:960dfc71c224 | 245 | y, // defines starting y position for ball |
el15mh | 9:960dfc71c224 | 246 | radius, // radius of ball |
el15mh | 9:960dfc71c224 | 247 | _control, // control method |
el15mh | 9:960dfc71c224 | 248 | _colour); // type of ball |
el15mh | 9:960dfc71c224 | 249 | |
el15mh | 9:960dfc71c224 | 250 | printGameParameters(_mazeIndex, |
el15mh | 9:960dfc71c224 | 251 | x, |
el15mh | 9:960dfc71c224 | 252 | y, |
el15mh | 9:960dfc71c224 | 253 | radius, |
el15mh | 9:960dfc71c224 | 254 | _control, |
el15mh | 9:960dfc71c224 | 255 | _colour, |
el15mh | 9:960dfc71c224 | 256 | _FPS); // prints all game settings to serial port |
el15mh | 9:960dfc71c224 | 257 | |
el15mh | 9:960dfc71c224 | 258 | int exit = 0; |
el15mh | 9:960dfc71c224 | 259 | while (exit == 0){ |
el15mh | 9:960dfc71c224 | 260 | |
el15mh | 9:960dfc71c224 | 261 | _engine._goal = false; |
el15mh | 9:960dfc71c224 | 262 | |
el15mh | 9:960dfc71c224 | 263 | // rendering screen |
el15mh | 9:960dfc71c224 | 264 | lcd.clear(); |
el15mh | 9:960dfc71c224 | 265 | _engine.draw(lcd); |
el15mh | 9:960dfc71c224 | 266 | lcd.refresh(); |
el15mh | 9:960dfc71c224 | 267 | |
el15mh | 9:960dfc71c224 | 268 | _engine.readInput(pad, device); |
el15mh | 9:960dfc71c224 | 269 | _engine.update(lcd); |
el15mh | 9:960dfc71c224 | 270 | |
el15mh | 9:960dfc71c224 | 271 | wait_ms(_FPS); |
el15mh | 9:960dfc71c224 | 272 | |
el15mh | 9:960dfc71c224 | 273 | if (_engine.checkGoal()){ |
el15mh | 9:960dfc71c224 | 274 | |
el15mh | 9:960dfc71c224 | 275 | animateStickman(lcd, pad, animate); |
el15mh | 9:960dfc71c224 | 276 | exit ++; |
el15mh | 9:960dfc71c224 | 277 | } |
el15mh | 9:960dfc71c224 | 278 | |
el15mh | 9:960dfc71c224 | 279 | // get direction of the joystick |
el15mh | 9:960dfc71c224 | 280 | char d = pad.get_direction(); |
el15mh | 9:960dfc71c224 | 281 | if (pad.check_event(Gamepad::BACK_PRESSED)){ |
el15mh | 9:960dfc71c224 | 282 | |
el15mh | 9:960dfc71c224 | 283 | exit++; |
el15mh | 9:960dfc71c224 | 284 | } |
el15mh | 9:960dfc71c224 | 285 | } |
el15mh | 9:960dfc71c224 | 286 | } |
el15mh | 9:960dfc71c224 | 287 | |
el15mh | 9:960dfc71c224 | 288 | /** |
el15mh | 9:960dfc71c224 | 289 | * @details - Returns a random number between two set values |
el15mh | 9:960dfc71c224 | 290 | */ |
el15mh | 9:960dfc71c224 | 291 | int Menu::randomMazeIndexGenerator(int difficulty) |
el15mh | 9:960dfc71c224 | 292 | { |
el15mh | 9:960dfc71c224 | 293 | // generates a random number between a pair of values |
el15mh | 9:960dfc71c224 | 294 | // based on the difficulty level chosen |
el15mh | 9:960dfc71c224 | 295 | |
el15mh | 9:960dfc71c224 | 296 | _difficulty = difficulty; |
el15mh | 9:960dfc71c224 | 297 | |
el15mh | 9:960dfc71c224 | 298 | if (_difficulty == 1) { |
el15mh | 9:960dfc71c224 | 299 | |
el15mh | 9:960dfc71c224 | 300 | _mazeIndex = rand() % 3; // random number between 0 and 2 |
el15mh | 9:960dfc71c224 | 301 | } |
el15mh | 9:960dfc71c224 | 302 | |
el15mh | 9:960dfc71c224 | 303 | else if (difficulty == 2){ |
el15mh | 9:960dfc71c224 | 304 | |
el15mh | 9:960dfc71c224 | 305 | _mazeIndex = rand() % 3 + 3; // random number between 3 and 5 |
el15mh | 9:960dfc71c224 | 306 | } |
el15mh | 9:960dfc71c224 | 307 | |
el15mh | 9:960dfc71c224 | 308 | else if (difficulty == 3){ |
el15mh | 9:960dfc71c224 | 309 | |
el15mh | 9:960dfc71c224 | 310 | _mazeIndex = rand() % 3 + 6; // random number between 6 and 8 |
el15mh | 9:960dfc71c224 | 311 | } |
el15mh | 9:960dfc71c224 | 312 | |
el15mh | 9:960dfc71c224 | 313 | else { |
el15mh | 9:960dfc71c224 | 314 | |
el15mh | 9:960dfc71c224 | 315 | _mazeIndex = 9; // no random number as only one maze at this level |
el15mh | 9:960dfc71c224 | 316 | } |
el15mh | 9:960dfc71c224 | 317 | |
el15mh | 9:960dfc71c224 | 318 | return _mazeIndex; |
el15mh | 9:960dfc71c224 | 319 | } |
el15mh | 9:960dfc71c224 | 320 | |
el15mh | 9:960dfc71c224 | 321 | /** |
el15mh | 9:960dfc71c224 | 322 | * @details - Prints all chosen game parameters to serial port - used mostly for debugging. |
el15mh | 9:960dfc71c224 | 323 | */ |
el15mh | 9:960dfc71c224 | 324 | void Menu::printGameParameters(int mazeIndex, |
el15mh | 9:960dfc71c224 | 325 | int x, |
el15mh | 9:960dfc71c224 | 326 | int y, |
el15mh | 9:960dfc71c224 | 327 | int radius, |
el15mh | 9:960dfc71c224 | 328 | bool control, |
el15mh | 9:960dfc71c224 | 329 | bool colour, |
el15mh | 9:960dfc71c224 | 330 | float FPS) |
el15mh | 9:960dfc71c224 | 331 | { |
el15mh | 9:960dfc71c224 | 332 | int _x = x; |
el15mh | 9:960dfc71c224 | 333 | int _y = y; |
el15mh | 9:960dfc71c224 | 334 | int _radius = radius; |
el15mh | 9:960dfc71c224 | 335 | bool _control = control; |
el15mh | 9:960dfc71c224 | 336 | bool _colour = colour; |
el15mh | 9:960dfc71c224 | 337 | float _fps = FPS; |
el15mh | 9:960dfc71c224 | 338 | |
el15mh | 9:960dfc71c224 | 339 | // printf out all game parameters |
el15mh | 9:960dfc71c224 | 340 | printf("Game parameters: \n"); |
el15mh | 9:960dfc71c224 | 341 | printf("Difficulty = %i \n", _difficulty); |
el15mh | 9:960dfc71c224 | 342 | printf("Maze Index = %i \n", _mazeIndex); |
el15mh | 9:960dfc71c224 | 343 | printf("Ball position = (%i, %i)\n", _x, _y); |
el15mh | 9:960dfc71c224 | 344 | printf("Ball radius = %i \n", _radius); |
el15mh | 9:960dfc71c224 | 345 | printf("Game speed = %f \n", _fps); |
el15mh | 9:960dfc71c224 | 346 | |
el15mh | 9:960dfc71c224 | 347 | if (_colour){ |
el15mh | 9:960dfc71c224 | 348 | printf("Ball colour: outline \n"); |
el15mh | 9:960dfc71c224 | 349 | } |
el15mh | 9:960dfc71c224 | 350 | if (!_colour){ |
el15mh | 9:960dfc71c224 | 351 | printf("Ball colour: black \n"); |
el15mh | 9:960dfc71c224 | 352 | } |
el15mh | 9:960dfc71c224 | 353 | if (_control){ |
el15mh | 9:960dfc71c224 | 354 | printf("Control method: Joystick \n"); |
el15mh | 9:960dfc71c224 | 355 | } |
el15mh | 9:960dfc71c224 | 356 | if (!_control){ |
el15mh | 9:960dfc71c224 | 357 | printf("Control method: Accelerometer \n"); |
el15mh | 9:960dfc71c224 | 358 | } |
el15mh | 9:960dfc71c224 | 359 | printf("\n\n ---NEW LINE---\n\n"); |
el15mh | 9:960dfc71c224 | 360 | |
el15mh | 9:960dfc71c224 | 361 | } |
el15mh | 9:960dfc71c224 | 362 | |
el15mh | 9:960dfc71c224 | 363 | /** |
el15mh | 9:960dfc71c224 | 364 | * @details - Game Options Function to allow user to choose game style. |
el15mh | 9:960dfc71c224 | 365 | */ |
el15mh | 9:960dfc71c224 | 366 | void Menu::options(N5110 &lcd, Gamepad &pad, Animations &animate, bool tone) |
el15mh | 9:960dfc71c224 | 367 | { |
el15mh | 9:960dfc71c224 | 368 | int exit = 0; |
el15mh | 9:960dfc71c224 | 369 | int selected = 0; |
el15mh | 9:960dfc71c224 | 370 | wait_ms(250); |
el15mh | 9:960dfc71c224 | 371 | |
el15mh | 9:960dfc71c224 | 372 | while(exit == 0) { |
el15mh | 9:960dfc71c224 | 373 | |
el15mh | 9:960dfc71c224 | 374 | // get direction of the joystick |
el15mh | 9:960dfc71c224 | 375 | char d = pad.get_direction(); |
el15mh | 9:960dfc71c224 | 376 | |
el15mh | 9:960dfc71c224 | 377 | if ((d == NW) || |
el15mh | 9:960dfc71c224 | 378 | (d == N) || |
el15mh | 9:960dfc71c224 | 379 | (d == NE)){ |
el15mh | 9:960dfc71c224 | 380 | |
el15mh | 9:960dfc71c224 | 381 | if (_tone){ |
el15mh | 9:960dfc71c224 | 382 | pad.tone(G_NOTE, 0.20); |
el15mh | 9:960dfc71c224 | 383 | } |
el15mh | 9:960dfc71c224 | 384 | selected -= 1; |
el15mh | 9:960dfc71c224 | 385 | } |
el15mh | 9:960dfc71c224 | 386 | |
el15mh | 9:960dfc71c224 | 387 | if ((d == SW) || |
el15mh | 9:960dfc71c224 | 388 | (d == S) || |
el15mh | 9:960dfc71c224 | 389 | (d == SE)){ |
el15mh | 9:960dfc71c224 | 390 | |
el15mh | 9:960dfc71c224 | 391 | if (_tone){ |
el15mh | 9:960dfc71c224 | 392 | pad.tone(G_NOTE, 0.20); |
el15mh | 9:960dfc71c224 | 393 | } |
el15mh | 9:960dfc71c224 | 394 | selected += 1; |
el15mh | 9:960dfc71c224 | 395 | } |
el15mh | 9:960dfc71c224 | 396 | |
el15mh | 9:960dfc71c224 | 397 | // printf("While loop 1 \n"); |
el15mh | 9:960dfc71c224 | 398 | // printf("Selected = %i \n", selected); |
el15mh | 9:960dfc71c224 | 399 | switch (selected) { |
el15mh | 9:960dfc71c224 | 400 | |
el15mh | 9:960dfc71c224 | 401 | case 1: |
el15mh | 9:960dfc71c224 | 402 | |
el15mh | 9:960dfc71c224 | 403 | lcd.clear(); |
el15mh | 9:960dfc71c224 | 404 | // displays options page with indicator on first |
el15mh | 9:960dfc71c224 | 405 | lcd.printString("Game Options:", 0, 0); |
el15mh | 9:960dfc71c224 | 406 | lcd.printString(">Difficulty", 0, 2); |
el15mh | 9:960dfc71c224 | 407 | lcd.printString(" Ball Colour", 0, 3); |
el15mh | 9:960dfc71c224 | 408 | lcd.printString(" Control", 0, 4); |
el15mh | 9:960dfc71c224 | 409 | lcd.printString(" Game speed ", 0, 5); |
el15mh | 9:960dfc71c224 | 410 | lcd.refresh(); |
el15mh | 9:960dfc71c224 | 411 | |
el15mh | 9:960dfc71c224 | 412 | wait_ms(250); |
el15mh | 9:960dfc71c224 | 413 | |
el15mh | 9:960dfc71c224 | 414 | if ((pad.check_event(Gamepad::A_PRESSED) || |
el15mh | 9:960dfc71c224 | 415 | pad.check_event(Gamepad::JOY_PRESSED)) || |
el15mh | 9:960dfc71c224 | 416 | (d == E)) { |
el15mh | 9:960dfc71c224 | 417 | |
el15mh | 9:960dfc71c224 | 418 | if (_tone){ |
el15mh | 9:960dfc71c224 | 419 | pad.tone(C_NOTE, 0.20); |
el15mh | 9:960dfc71c224 | 420 | } |
el15mh | 9:960dfc71c224 | 421 | difficultyOptions(lcd, pad); |
el15mh | 9:960dfc71c224 | 422 | } |
el15mh | 9:960dfc71c224 | 423 | |
el15mh | 9:960dfc71c224 | 424 | |
el15mh | 9:960dfc71c224 | 425 | break; |
el15mh | 9:960dfc71c224 | 426 | |
el15mh | 9:960dfc71c224 | 427 | case 2: |
el15mh | 9:960dfc71c224 | 428 | |
el15mh | 9:960dfc71c224 | 429 | lcd.clear(); |
el15mh | 9:960dfc71c224 | 430 | // displays options page with indicator on second |
el15mh | 9:960dfc71c224 | 431 | lcd.printString("Game Options:", 0, 0); |
el15mh | 9:960dfc71c224 | 432 | lcd.printString(" Difficulty", 0, 2); |
el15mh | 9:960dfc71c224 | 433 | lcd.printString(">Ball Colour", 0, 3); |
el15mh | 9:960dfc71c224 | 434 | lcd.printString(" Control", 0, 4); |
el15mh | 9:960dfc71c224 | 435 | lcd.printString(" Game speed ", 0, 5); |
el15mh | 9:960dfc71c224 | 436 | lcd.refresh(); |
el15mh | 9:960dfc71c224 | 437 | |
el15mh | 9:960dfc71c224 | 438 | wait_ms(250); |
el15mh | 9:960dfc71c224 | 439 | |
el15mh | 9:960dfc71c224 | 440 | // if second option selected |
el15mh | 9:960dfc71c224 | 441 | if ((pad.check_event(Gamepad::A_PRESSED) || |
el15mh | 9:960dfc71c224 | 442 | pad.check_event(Gamepad::JOY_PRESSED)) || |
el15mh | 9:960dfc71c224 | 443 | (d == E)) { |
el15mh | 9:960dfc71c224 | 444 | |
el15mh | 9:960dfc71c224 | 445 | if (_tone){ |
el15mh | 9:960dfc71c224 | 446 | pad.tone(C_NOTE, 0.20); |
el15mh | 9:960dfc71c224 | 447 | } |
el15mh | 9:960dfc71c224 | 448 | ballColourOptions(lcd, pad, animate); |
el15mh | 9:960dfc71c224 | 449 | } |
el15mh | 9:960dfc71c224 | 450 | |
el15mh | 9:960dfc71c224 | 451 | |
el15mh | 9:960dfc71c224 | 452 | break; |
el15mh | 9:960dfc71c224 | 453 | |
el15mh | 9:960dfc71c224 | 454 | case 3: |
el15mh | 9:960dfc71c224 | 455 | |
el15mh | 9:960dfc71c224 | 456 | lcd.clear(); |
el15mh | 9:960dfc71c224 | 457 | // displays options page with indicator on first |
el15mh | 9:960dfc71c224 | 458 | lcd.printString("Game Options:", 0, 0); |
el15mh | 9:960dfc71c224 | 459 | lcd.printString(" Difficulty", 0, 2); |
el15mh | 9:960dfc71c224 | 460 | lcd.printString(" Ball Colour", 0, 3); |
el15mh | 9:960dfc71c224 | 461 | lcd.printString(">Control", 0, 4); |
el15mh | 9:960dfc71c224 | 462 | lcd.printString(" Game speed ", 0, 5); |
el15mh | 9:960dfc71c224 | 463 | lcd.refresh(); |
el15mh | 9:960dfc71c224 | 464 | |
el15mh | 9:960dfc71c224 | 465 | wait_ms(250); |
el15mh | 9:960dfc71c224 | 466 | |
el15mh | 9:960dfc71c224 | 467 | if ((pad.check_event(Gamepad::A_PRESSED) || |
el15mh | 9:960dfc71c224 | 468 | pad.check_event(Gamepad::JOY_PRESSED)) || |
el15mh | 9:960dfc71c224 | 469 | (d == E)) { |
el15mh | 9:960dfc71c224 | 470 | |
el15mh | 9:960dfc71c224 | 471 | if (_tone){ |
el15mh | 9:960dfc71c224 | 472 | pad.tone(C_NOTE, 0.20); |
el15mh | 9:960dfc71c224 | 473 | } |
el15mh | 9:960dfc71c224 | 474 | controlOptions(lcd, pad, animate); |
el15mh | 9:960dfc71c224 | 475 | } |
el15mh | 9:960dfc71c224 | 476 | |
el15mh | 9:960dfc71c224 | 477 | |
el15mh | 9:960dfc71c224 | 478 | break; |
el15mh | 9:960dfc71c224 | 479 | |
el15mh | 9:960dfc71c224 | 480 | case 4: |
el15mh | 9:960dfc71c224 | 481 | |
el15mh | 9:960dfc71c224 | 482 | lcd.clear(); |
el15mh | 9:960dfc71c224 | 483 | // displays options page with indicator on first |
el15mh | 9:960dfc71c224 | 484 | lcd.printString("Game Options:", 0, 0); |
el15mh | 9:960dfc71c224 | 485 | lcd.printString(" Difficulty", 0, 2); |
el15mh | 9:960dfc71c224 | 486 | lcd.printString(" Ball Colour", 0, 3); |
el15mh | 9:960dfc71c224 | 487 | lcd.printString(" Control", 0, 4); |
el15mh | 9:960dfc71c224 | 488 | lcd.printString(">Game speed ", 0, 5); |
el15mh | 9:960dfc71c224 | 489 | lcd.refresh(); |
el15mh | 9:960dfc71c224 | 490 | |
el15mh | 9:960dfc71c224 | 491 | wait_ms(250); |
el15mh | 9:960dfc71c224 | 492 | |
el15mh | 9:960dfc71c224 | 493 | if ((pad.check_event(Gamepad::A_PRESSED) || |
el15mh | 9:960dfc71c224 | 494 | pad.check_event(Gamepad::JOY_PRESSED)) || |
el15mh | 9:960dfc71c224 | 495 | (d == E)) { |
el15mh | 9:960dfc71c224 | 496 | |
el15mh | 9:960dfc71c224 | 497 | if (_tone){ |
el15mh | 9:960dfc71c224 | 498 | pad.tone(C_NOTE, 0.20); |
el15mh | 9:960dfc71c224 | 499 | } |
el15mh | 9:960dfc71c224 | 500 | speedSettings(lcd, pad); |
el15mh | 9:960dfc71c224 | 501 | } |
el15mh | 9:960dfc71c224 | 502 | |
el15mh | 9:960dfc71c224 | 503 | |
el15mh | 9:960dfc71c224 | 504 | break; |
el15mh | 9:960dfc71c224 | 505 | |
el15mh | 9:960dfc71c224 | 506 | |
el15mh | 9:960dfc71c224 | 507 | |
el15mh | 9:960dfc71c224 | 508 | default: |
el15mh | 9:960dfc71c224 | 509 | |
el15mh | 9:960dfc71c224 | 510 | selected = 1; |
el15mh | 9:960dfc71c224 | 511 | |
el15mh | 9:960dfc71c224 | 512 | break; |
el15mh | 9:960dfc71c224 | 513 | } |
el15mh | 9:960dfc71c224 | 514 | |
el15mh | 9:960dfc71c224 | 515 | if ((pad.check_event(Gamepad::BACK_PRESSED)) || |
el15mh | 9:960dfc71c224 | 516 | (d == W)){ |
el15mh | 9:960dfc71c224 | 517 | |
el15mh | 9:960dfc71c224 | 518 | exit++; |
el15mh | 9:960dfc71c224 | 519 | } |
el15mh | 9:960dfc71c224 | 520 | } |
el15mh | 9:960dfc71c224 | 521 | } |
el15mh | 9:960dfc71c224 | 522 | |
el15mh | 9:960dfc71c224 | 523 | /** |
el15mh | 9:960dfc71c224 | 524 | * @details - LCD Settings Function to allow user to alter appearance of game on LCD. |
el15mh | 9:960dfc71c224 | 525 | */ |
el15mh | 9:960dfc71c224 | 526 | void Menu::lcdSettings(N5110 &lcd, Gamepad &pad, Animations &animate) |
el15mh | 9:960dfc71c224 | 527 | { |
el15mh | 9:960dfc71c224 | 528 | int exit = 0; |
el15mh | 9:960dfc71c224 | 529 | int selected = 0; |
el15mh | 9:960dfc71c224 | 530 | wait_ms(250); |
el15mh | 9:960dfc71c224 | 531 | |
el15mh | 9:960dfc71c224 | 532 | while(exit == 0) { |
el15mh | 9:960dfc71c224 | 533 | |
el15mh | 9:960dfc71c224 | 534 | char d = pad.get_direction(); |
el15mh | 9:960dfc71c224 | 535 | |
el15mh | 9:960dfc71c224 | 536 | if ((d == NW) || |
el15mh | 9:960dfc71c224 | 537 | (d == N) || |
el15mh | 9:960dfc71c224 | 538 | (d == NE)){ |
el15mh | 9:960dfc71c224 | 539 | |
el15mh | 9:960dfc71c224 | 540 | if (_tone){ |
el15mh | 9:960dfc71c224 | 541 | pad.tone(G_NOTE, 0.20); |
el15mh | 9:960dfc71c224 | 542 | } |
el15mh | 9:960dfc71c224 | 543 | selected -= 1; |
el15mh | 9:960dfc71c224 | 544 | } |
el15mh | 9:960dfc71c224 | 545 | |
el15mh | 9:960dfc71c224 | 546 | if ((d == SW) || |
el15mh | 9:960dfc71c224 | 547 | (d == S) || |
el15mh | 9:960dfc71c224 | 548 | (d == SE)){ |
el15mh | 9:960dfc71c224 | 549 | |
el15mh | 9:960dfc71c224 | 550 | if (_tone){ |
el15mh | 9:960dfc71c224 | 551 | pad.tone(G_NOTE, 0.20); |
el15mh | 9:960dfc71c224 | 552 | } |
el15mh | 9:960dfc71c224 | 553 | selected += 1; |
el15mh | 9:960dfc71c224 | 554 | } |
el15mh | 9:960dfc71c224 | 555 | |
el15mh | 9:960dfc71c224 | 556 | // printf("While loop 1 \n"); |
el15mh | 9:960dfc71c224 | 557 | // printf("Selected = %i \n", selected); |
el15mh | 9:960dfc71c224 | 558 | switch (selected) { |
el15mh | 9:960dfc71c224 | 559 | |
el15mh | 9:960dfc71c224 | 560 | case 1: |
el15mh | 9:960dfc71c224 | 561 | |
el15mh | 9:960dfc71c224 | 562 | lcd.clear(); |
el15mh | 9:960dfc71c224 | 563 | // displays options page with indicator on first |
el15mh | 9:960dfc71c224 | 564 | lcd.printString("LCD Settings:", 0, 0); |
el15mh | 9:960dfc71c224 | 565 | lcd.printString(">Brightness", 0, 2); |
el15mh | 9:960dfc71c224 | 566 | lcd.printString(" Invert Colour", 0, 3); |
el15mh | 9:960dfc71c224 | 567 | lcd.refresh(); |
el15mh | 9:960dfc71c224 | 568 | |
el15mh | 9:960dfc71c224 | 569 | wait_ms(250); |
el15mh | 9:960dfc71c224 | 570 | |
el15mh | 9:960dfc71c224 | 571 | if ((pad.check_event(Gamepad::A_PRESSED) || |
el15mh | 9:960dfc71c224 | 572 | pad.check_event(Gamepad::JOY_PRESSED)) || |
el15mh | 9:960dfc71c224 | 573 | (d == E)) { |
el15mh | 9:960dfc71c224 | 574 | |
el15mh | 9:960dfc71c224 | 575 | if (_tone){ |
el15mh | 9:960dfc71c224 | 576 | pad.tone(C_NOTE, 0.20); |
el15mh | 9:960dfc71c224 | 577 | } |
el15mh | 9:960dfc71c224 | 578 | lcdBackgroundColour(lcd, pad, animate); |
el15mh | 9:960dfc71c224 | 579 | } |
el15mh | 9:960dfc71c224 | 580 | |
el15mh | 9:960dfc71c224 | 581 | break; |
el15mh | 9:960dfc71c224 | 582 | |
el15mh | 9:960dfc71c224 | 583 | case 2: |
el15mh | 9:960dfc71c224 | 584 | |
el15mh | 9:960dfc71c224 | 585 | lcd.clear(); |
el15mh | 9:960dfc71c224 | 586 | // displays options page with indicator on second |
el15mh | 9:960dfc71c224 | 587 | lcd.printString("LCD Settings:", 0, 0); |
el15mh | 9:960dfc71c224 | 588 | lcd.printString(" Brightness", 0, 2); |
el15mh | 9:960dfc71c224 | 589 | lcd.printString(">Invert Colour", 0, 3); |
el15mh | 9:960dfc71c224 | 590 | lcd.refresh(); |
el15mh | 9:960dfc71c224 | 591 | |
el15mh | 9:960dfc71c224 | 592 | wait_ms(250); |
el15mh | 9:960dfc71c224 | 593 | |
el15mh | 9:960dfc71c224 | 594 | // if second option selected |
el15mh | 9:960dfc71c224 | 595 | if ((pad.check_event(Gamepad::A_PRESSED) || |
el15mh | 9:960dfc71c224 | 596 | pad.check_event(Gamepad::JOY_PRESSED)) || |
el15mh | 9:960dfc71c224 | 597 | (d == E)) { |
el15mh | 9:960dfc71c224 | 598 | |
el15mh | 9:960dfc71c224 | 599 | if (_tone){ |
el15mh | 9:960dfc71c224 | 600 | pad.tone(C_NOTE, 0.20); |
el15mh | 9:960dfc71c224 | 601 | } |
el15mh | 9:960dfc71c224 | 602 | lcdInverseColour(lcd, pad); |
el15mh | 9:960dfc71c224 | 603 | } |
el15mh | 9:960dfc71c224 | 604 | |
el15mh | 9:960dfc71c224 | 605 | break; |
el15mh | 9:960dfc71c224 | 606 | |
el15mh | 9:960dfc71c224 | 607 | default: |
el15mh | 9:960dfc71c224 | 608 | |
el15mh | 9:960dfc71c224 | 609 | selected = 1; |
el15mh | 9:960dfc71c224 | 610 | |
el15mh | 9:960dfc71c224 | 611 | break; |
el15mh | 9:960dfc71c224 | 612 | } |
el15mh | 9:960dfc71c224 | 613 | |
el15mh | 9:960dfc71c224 | 614 | if ((pad.check_event(Gamepad::BACK_PRESSED)) || |
el15mh | 9:960dfc71c224 | 615 | (d == W)){ |
el15mh | 9:960dfc71c224 | 616 | |
el15mh | 9:960dfc71c224 | 617 | exit++; |
el15mh | 9:960dfc71c224 | 618 | } |
el15mh | 9:960dfc71c224 | 619 | |
el15mh | 9:960dfc71c224 | 620 | } |
el15mh | 9:960dfc71c224 | 621 | |
el15mh | 9:960dfc71c224 | 622 | |
el15mh | 9:960dfc71c224 | 623 | } |
el15mh | 9:960dfc71c224 | 624 | |
el15mh | 9:960dfc71c224 | 625 | /** |
el15mh | 9:960dfc71c224 | 626 | * @details - Sound Settings to allow user to turn sound on or off |
el15mh | 9:960dfc71c224 | 627 | */ |
el15mh | 9:960dfc71c224 | 628 | void Menu::soundSettings(N5110 &lcd, Gamepad &pad, Animations &animate) |
el15mh | 9:960dfc71c224 | 629 | { |
el15mh | 9:960dfc71c224 | 630 | int exit = 0; |
el15mh | 9:960dfc71c224 | 631 | |
el15mh | 9:960dfc71c224 | 632 | while (exit == 0){ |
el15mh | 9:960dfc71c224 | 633 | |
el15mh | 9:960dfc71c224 | 634 | // animate.soundSwitch(lcd, _tone); |
el15mh | 9:960dfc71c224 | 635 | |
el15mh | 9:960dfc71c224 | 636 | char d = pad.get_direction(); |
el15mh | 9:960dfc71c224 | 637 | |
el15mh | 9:960dfc71c224 | 638 | if (d == E){ |
el15mh | 9:960dfc71c224 | 639 | |
el15mh | 9:960dfc71c224 | 640 | _tone = false; |
el15mh | 9:960dfc71c224 | 641 | } |
el15mh | 9:960dfc71c224 | 642 | |
el15mh | 9:960dfc71c224 | 643 | if (d == W){ |
el15mh | 9:960dfc71c224 | 644 | |
el15mh | 9:960dfc71c224 | 645 | _tone = true; |
el15mh | 9:960dfc71c224 | 646 | pad.tone(G_NOTE, 0.20); |
el15mh | 9:960dfc71c224 | 647 | |
el15mh | 9:960dfc71c224 | 648 | } |
el15mh | 9:960dfc71c224 | 649 | |
el15mh | 9:960dfc71c224 | 650 | lcd.clear(); |
el15mh | 9:960dfc71c224 | 651 | // draw casing rectangle |
el15mh | 9:960dfc71c224 | 652 | lcd.drawRect(33, 27, 17, 9, FILL_TRANSPARENT); |
el15mh | 9:960dfc71c224 | 653 | |
el15mh | 9:960dfc71c224 | 654 | lcd.printString("Sound Settings", 0, 0); |
el15mh | 9:960dfc71c224 | 655 | lcd.printString(" ON OFF ", 0, 2); |
el15mh | 9:960dfc71c224 | 656 | |
el15mh | 9:960dfc71c224 | 657 | // casing rectangle is filled in one side |
el15mh | 9:960dfc71c224 | 658 | // depending on value of _tone |
el15mh | 9:960dfc71c224 | 659 | if (_tone){ |
el15mh | 9:960dfc71c224 | 660 | lcd.drawRect(34, 28, 7, 7, FILL_BLACK); |
el15mh | 9:960dfc71c224 | 661 | } |
el15mh | 9:960dfc71c224 | 662 | else { |
el15mh | 9:960dfc71c224 | 663 | lcd.drawRect(42, 28, 7, 7, FILL_BLACK); |
el15mh | 9:960dfc71c224 | 664 | } |
el15mh | 9:960dfc71c224 | 665 | |
el15mh | 9:960dfc71c224 | 666 | lcd.refresh(); |
el15mh | 9:960dfc71c224 | 667 | |
el15mh | 9:960dfc71c224 | 668 | wait_ms(10); |
el15mh | 9:960dfc71c224 | 669 | |
el15mh | 9:960dfc71c224 | 670 | |
el15mh | 9:960dfc71c224 | 671 | if ((pad.check_event(Gamepad::BACK_PRESSED)) || |
el15mh | 9:960dfc71c224 | 672 | (pad.check_event(Gamepad::A_PRESSED))){ |
el15mh | 9:960dfc71c224 | 673 | |
el15mh | 9:960dfc71c224 | 674 | if (_tone){ |
el15mh | 9:960dfc71c224 | 675 | pad.tone(C_NOTE, 0.20); |
el15mh | 9:960dfc71c224 | 676 | } |
el15mh | 9:960dfc71c224 | 677 | exit++; |
el15mh | 9:960dfc71c224 | 678 | } |
el15mh | 9:960dfc71c224 | 679 | } |
el15mh | 9:960dfc71c224 | 680 | |
el15mh | 9:960dfc71c224 | 681 | } |
el15mh | 9:960dfc71c224 | 682 | |
el15mh | 9:960dfc71c224 | 683 | /** |
el15mh | 9:960dfc71c224 | 684 | * @details - Control Options Function which allows user select control technique. |
el15mh | 9:960dfc71c224 | 685 | */ |
el15mh | 9:960dfc71c224 | 686 | void Menu::controlOptions(N5110 &lcd, Gamepad &pad, Animations &animate) |
el15mh | 9:960dfc71c224 | 687 | { |
el15mh | 9:960dfc71c224 | 688 | int selected = 0; |
el15mh | 9:960dfc71c224 | 689 | int exit = 0; |
el15mh | 9:960dfc71c224 | 690 | |
el15mh | 9:960dfc71c224 | 691 | wait_ms(250); |
el15mh | 9:960dfc71c224 | 692 | |
el15mh | 9:960dfc71c224 | 693 | while (exit == 0){ |
el15mh | 9:960dfc71c224 | 694 | |
el15mh | 9:960dfc71c224 | 695 | char d = pad.get_direction(); |
el15mh | 9:960dfc71c224 | 696 | |
el15mh | 9:960dfc71c224 | 697 | if (d == W){ |
el15mh | 9:960dfc71c224 | 698 | |
el15mh | 9:960dfc71c224 | 699 | if (_tone){ |
el15mh | 9:960dfc71c224 | 700 | pad.tone(G_NOTE, 0.20); |
el15mh | 9:960dfc71c224 | 701 | } |
el15mh | 9:960dfc71c224 | 702 | selected--; |
el15mh | 9:960dfc71c224 | 703 | } |
el15mh | 9:960dfc71c224 | 704 | |
el15mh | 9:960dfc71c224 | 705 | if (d == E){ |
el15mh | 9:960dfc71c224 | 706 | |
el15mh | 9:960dfc71c224 | 707 | if (_tone){ |
el15mh | 9:960dfc71c224 | 708 | pad.tone(G_NOTE, 0.20); |
el15mh | 9:960dfc71c224 | 709 | } |
el15mh | 9:960dfc71c224 | 710 | selected++; |
el15mh | 9:960dfc71c224 | 711 | } |
el15mh | 9:960dfc71c224 | 712 | |
el15mh | 9:960dfc71c224 | 713 | switch(selected){ |
el15mh | 9:960dfc71c224 | 714 | |
el15mh | 9:960dfc71c224 | 715 | case 1: |
el15mh | 9:960dfc71c224 | 716 | |
el15mh | 9:960dfc71c224 | 717 | lcd.clear(); |
el15mh | 9:960dfc71c224 | 718 | lcd.printString("Control: ", 0, 0); |
el15mh | 9:960dfc71c224 | 719 | lcd.printString(" Joystick ", 0, 2); |
el15mh | 9:960dfc71c224 | 720 | lcd.printString(" >", 0, 3); |
el15mh | 9:960dfc71c224 | 721 | animate.drawVerticalJoystick(lcd); |
el15mh | 9:960dfc71c224 | 722 | lcd.refresh(); |
el15mh | 9:960dfc71c224 | 723 | |
el15mh | 9:960dfc71c224 | 724 | wait_ms(250); |
el15mh | 9:960dfc71c224 | 725 | |
el15mh | 9:960dfc71c224 | 726 | if (pad.check_event(Gamepad::A_PRESSED)|| |
el15mh | 9:960dfc71c224 | 727 | pad.check_event(Gamepad::JOY_PRESSED)){ |
el15mh | 9:960dfc71c224 | 728 | |
el15mh | 9:960dfc71c224 | 729 | _control = true; |
el15mh | 9:960dfc71c224 | 730 | |
el15mh | 9:960dfc71c224 | 731 | if (_tone){ |
el15mh | 9:960dfc71c224 | 732 | pad.tone(C_NOTE, 0.20); |
el15mh | 9:960dfc71c224 | 733 | } |
el15mh | 9:960dfc71c224 | 734 | |
el15mh | 9:960dfc71c224 | 735 | animateJoystick(lcd, animate); |
el15mh | 9:960dfc71c224 | 736 | exit++; |
el15mh | 9:960dfc71c224 | 737 | } |
el15mh | 9:960dfc71c224 | 738 | |
el15mh | 9:960dfc71c224 | 739 | break; |
el15mh | 9:960dfc71c224 | 740 | |
el15mh | 9:960dfc71c224 | 741 | |
el15mh | 9:960dfc71c224 | 742 | case 2: |
el15mh | 9:960dfc71c224 | 743 | |
el15mh | 9:960dfc71c224 | 744 | lcd.clear(); |
el15mh | 9:960dfc71c224 | 745 | lcd.printString("Control: ", 0, 0); |
el15mh | 9:960dfc71c224 | 746 | lcd.printString(" Gamepad ", 0, 2); |
el15mh | 9:960dfc71c224 | 747 | lcd.printString("< ", 0, 3); |
el15mh | 9:960dfc71c224 | 748 | animate.drawVerticalGamepad(lcd); |
el15mh | 9:960dfc71c224 | 749 | lcd.refresh(); |
el15mh | 9:960dfc71c224 | 750 | |
el15mh | 9:960dfc71c224 | 751 | wait_ms(250); |
el15mh | 9:960dfc71c224 | 752 | |
el15mh | 9:960dfc71c224 | 753 | if (pad.check_event(Gamepad::A_PRESSED)|| |
el15mh | 9:960dfc71c224 | 754 | pad.check_event(Gamepad::JOY_PRESSED)){ |
el15mh | 9:960dfc71c224 | 755 | |
el15mh | 9:960dfc71c224 | 756 | _control = false; |
el15mh | 9:960dfc71c224 | 757 | |
el15mh | 9:960dfc71c224 | 758 | if (_tone){ |
el15mh | 9:960dfc71c224 | 759 | pad.tone(C_NOTE, 0.20); |
el15mh | 9:960dfc71c224 | 760 | } |
el15mh | 9:960dfc71c224 | 761 | |
el15mh | 9:960dfc71c224 | 762 | animateGamepad(lcd, animate); |
el15mh | 9:960dfc71c224 | 763 | exit++; |
el15mh | 9:960dfc71c224 | 764 | } |
el15mh | 9:960dfc71c224 | 765 | |
el15mh | 9:960dfc71c224 | 766 | break; |
el15mh | 9:960dfc71c224 | 767 | |
el15mh | 9:960dfc71c224 | 768 | default: |
el15mh | 9:960dfc71c224 | 769 | |
el15mh | 9:960dfc71c224 | 770 | selected = 1; |
el15mh | 9:960dfc71c224 | 771 | |
el15mh | 9:960dfc71c224 | 772 | break; |
el15mh | 9:960dfc71c224 | 773 | |
el15mh | 9:960dfc71c224 | 774 | } |
el15mh | 9:960dfc71c224 | 775 | |
el15mh | 9:960dfc71c224 | 776 | if (pad.check_event(Gamepad::BACK_PRESSED)){ |
el15mh | 9:960dfc71c224 | 777 | |
el15mh | 9:960dfc71c224 | 778 | exit++; |
el15mh | 9:960dfc71c224 | 779 | } |
el15mh | 9:960dfc71c224 | 780 | |
el15mh | 9:960dfc71c224 | 781 | } |
el15mh | 9:960dfc71c224 | 782 | } |
el15mh | 9:960dfc71c224 | 783 | |
el15mh | 9:960dfc71c224 | 784 | /** |
el15mh | 9:960dfc71c224 | 785 | * @details - Difficulty Options Function to allow player to select difficulty level. |
el15mh | 9:960dfc71c224 | 786 | */ |
el15mh | 9:960dfc71c224 | 787 | void Menu::difficultyOptions(N5110 &lcd, Gamepad &pad) |
el15mh | 9:960dfc71c224 | 788 | { |
el15mh | 9:960dfc71c224 | 789 | int selected = 0; |
el15mh | 9:960dfc71c224 | 790 | int exit = 0; |
el15mh | 9:960dfc71c224 | 791 | wait_ms(250); |
el15mh | 9:960dfc71c224 | 792 | |
el15mh | 9:960dfc71c224 | 793 | while(exit == 0){ |
el15mh | 9:960dfc71c224 | 794 | |
el15mh | 9:960dfc71c224 | 795 | char d = pad.get_direction(); |
el15mh | 9:960dfc71c224 | 796 | |
el15mh | 9:960dfc71c224 | 797 | if ((d == NW) || |
el15mh | 9:960dfc71c224 | 798 | (d == N) || |
el15mh | 9:960dfc71c224 | 799 | (d == NE)){ |
el15mh | 9:960dfc71c224 | 800 | |
el15mh | 9:960dfc71c224 | 801 | if (_tone){ |
el15mh | 9:960dfc71c224 | 802 | pad.tone(G_NOTE, 0.20); |
el15mh | 9:960dfc71c224 | 803 | } |
el15mh | 9:960dfc71c224 | 804 | selected -= 1; |
el15mh | 9:960dfc71c224 | 805 | } |
el15mh | 9:960dfc71c224 | 806 | |
el15mh | 9:960dfc71c224 | 807 | if ((d == SW) || |
el15mh | 9:960dfc71c224 | 808 | (d == S) || |
el15mh | 9:960dfc71c224 | 809 | (d == SE)){ |
el15mh | 9:960dfc71c224 | 810 | |
el15mh | 9:960dfc71c224 | 811 | if (_tone){ |
el15mh | 9:960dfc71c224 | 812 | pad.tone(G_NOTE, 0.20); |
el15mh | 9:960dfc71c224 | 813 | } |
el15mh | 9:960dfc71c224 | 814 | selected += 1; |
el15mh | 9:960dfc71c224 | 815 | } |
el15mh | 9:960dfc71c224 | 816 | |
el15mh | 9:960dfc71c224 | 817 | switch(selected){ |
el15mh | 9:960dfc71c224 | 818 | |
el15mh | 9:960dfc71c224 | 819 | case 1: |
el15mh | 9:960dfc71c224 | 820 | |
el15mh | 9:960dfc71c224 | 821 | lcd.clear(); |
el15mh | 9:960dfc71c224 | 822 | lcd.printString("Difficulty: ", 0, 0); |
el15mh | 9:960dfc71c224 | 823 | lcd.printString(">Easy", 0, 2); |
el15mh | 9:960dfc71c224 | 824 | lcd.printString(" Medium", 0, 3); |
el15mh | 9:960dfc71c224 | 825 | lcd.printString(" Hard", 0, 4); |
el15mh | 9:960dfc71c224 | 826 | lcd.printString(" Extreme", 0, 5); |
el15mh | 9:960dfc71c224 | 827 | lcd.refresh(); |
el15mh | 9:960dfc71c224 | 828 | |
el15mh | 9:960dfc71c224 | 829 | wait_ms(250); // 250ms propogation delay |
el15mh | 9:960dfc71c224 | 830 | |
el15mh | 9:960dfc71c224 | 831 | if ((pad.check_event(Gamepad::A_PRESSED) || |
el15mh | 9:960dfc71c224 | 832 | pad.check_event(Gamepad::JOY_PRESSED)) || |
el15mh | 9:960dfc71c224 | 833 | (d == E)) { |
el15mh | 9:960dfc71c224 | 834 | |
el15mh | 9:960dfc71c224 | 835 | _difficulty = 1; |
el15mh | 9:960dfc71c224 | 836 | |
el15mh | 9:960dfc71c224 | 837 | if (_tone){ |
el15mh | 9:960dfc71c224 | 838 | pad.tone(C_NOTE, 0.20); |
el15mh | 9:960dfc71c224 | 839 | } |
el15mh | 9:960dfc71c224 | 840 | |
el15mh | 9:960dfc71c224 | 841 | lcd.clear(); |
el15mh | 9:960dfc71c224 | 842 | lcd.printString(" EASY", 0, 1); |
el15mh | 9:960dfc71c224 | 843 | lcd.printString(" MODE", 0, 2); |
el15mh | 9:960dfc71c224 | 844 | lcd.refresh(); |
el15mh | 9:960dfc71c224 | 845 | wait(2); |
el15mh | 9:960dfc71c224 | 846 | |
el15mh | 9:960dfc71c224 | 847 | exit++; |
el15mh | 9:960dfc71c224 | 848 | } |
el15mh | 9:960dfc71c224 | 849 | |
el15mh | 9:960dfc71c224 | 850 | break; |
el15mh | 9:960dfc71c224 | 851 | |
el15mh | 9:960dfc71c224 | 852 | case 2: |
el15mh | 9:960dfc71c224 | 853 | |
el15mh | 9:960dfc71c224 | 854 | lcd.clear(); |
el15mh | 9:960dfc71c224 | 855 | lcd.printString("Difficulty: ", 0, 0); |
el15mh | 9:960dfc71c224 | 856 | lcd.printString(" Easy", 0, 2); |
el15mh | 9:960dfc71c224 | 857 | lcd.printString(">Medium", 0, 3); |
el15mh | 9:960dfc71c224 | 858 | lcd.printString(" Hard", 0, 4); |
el15mh | 9:960dfc71c224 | 859 | lcd.printString(" Extreme", 0, 5); |
el15mh | 9:960dfc71c224 | 860 | lcd.refresh(); |
el15mh | 9:960dfc71c224 | 861 | |
el15mh | 9:960dfc71c224 | 862 | wait_ms(250); // 250ms propogation delay |
el15mh | 9:960dfc71c224 | 863 | |
el15mh | 9:960dfc71c224 | 864 | if ((pad.check_event(Gamepad::A_PRESSED) || |
el15mh | 9:960dfc71c224 | 865 | pad.check_event(Gamepad::JOY_PRESSED)) || |
el15mh | 9:960dfc71c224 | 866 | (d == E)) { |
el15mh | 9:960dfc71c224 | 867 | |
el15mh | 9:960dfc71c224 | 868 | _difficulty = 2; |
el15mh | 9:960dfc71c224 | 869 | |
el15mh | 9:960dfc71c224 | 870 | if (_tone){ |
el15mh | 9:960dfc71c224 | 871 | pad.tone(C_NOTE, 0.20); |
el15mh | 9:960dfc71c224 | 872 | } |
el15mh | 9:960dfc71c224 | 873 | |
el15mh | 9:960dfc71c224 | 874 | lcd.clear(); |
el15mh | 9:960dfc71c224 | 875 | lcd.printString(" MEDIUM", 0, 1); |
el15mh | 9:960dfc71c224 | 876 | lcd.printString(" MODE", 0, 2); |
el15mh | 9:960dfc71c224 | 877 | lcd.refresh(); |
el15mh | 9:960dfc71c224 | 878 | wait(2); |
el15mh | 9:960dfc71c224 | 879 | |
el15mh | 9:960dfc71c224 | 880 | exit++; |
el15mh | 9:960dfc71c224 | 881 | } |
el15mh | 9:960dfc71c224 | 882 | |
el15mh | 9:960dfc71c224 | 883 | break; |
el15mh | 9:960dfc71c224 | 884 | |
el15mh | 9:960dfc71c224 | 885 | case 3: |
el15mh | 9:960dfc71c224 | 886 | |
el15mh | 9:960dfc71c224 | 887 | lcd.clear(); |
el15mh | 9:960dfc71c224 | 888 | lcd.printString("Difficulty: ", 0, 0); |
el15mh | 9:960dfc71c224 | 889 | lcd.printString(" Easy", 0, 2); |
el15mh | 9:960dfc71c224 | 890 | lcd.printString(" Medium", 0, 3); |
el15mh | 9:960dfc71c224 | 891 | lcd.printString(">Hard ", 0, 4); |
el15mh | 9:960dfc71c224 | 892 | lcd.printString(" Extreme ", 0, 5); |
el15mh | 9:960dfc71c224 | 893 | lcd.refresh(); |
el15mh | 9:960dfc71c224 | 894 | |
el15mh | 9:960dfc71c224 | 895 | wait_ms(250); // 250ms propogation delay |
el15mh | 9:960dfc71c224 | 896 | |
el15mh | 9:960dfc71c224 | 897 | if ((pad.check_event(Gamepad::A_PRESSED) || |
el15mh | 9:960dfc71c224 | 898 | pad.check_event(Gamepad::JOY_PRESSED)) || |
el15mh | 9:960dfc71c224 | 899 | (d == E)) { |
el15mh | 9:960dfc71c224 | 900 | |
el15mh | 9:960dfc71c224 | 901 | _difficulty = 3; |
el15mh | 9:960dfc71c224 | 902 | |
el15mh | 9:960dfc71c224 | 903 | if (_tone){ |
el15mh | 9:960dfc71c224 | 904 | pad.tone(C_NOTE, 0.20); |
el15mh | 9:960dfc71c224 | 905 | } |
el15mh | 9:960dfc71c224 | 906 | |
el15mh | 9:960dfc71c224 | 907 | lcd.clear(); |
el15mh | 9:960dfc71c224 | 908 | lcd.printString(" HARD", 0, 1); |
el15mh | 9:960dfc71c224 | 909 | lcd.printString(" MODE", 0, 2); |
el15mh | 9:960dfc71c224 | 910 | lcd.refresh(); |
el15mh | 9:960dfc71c224 | 911 | wait(2); |
el15mh | 9:960dfc71c224 | 912 | |
el15mh | 9:960dfc71c224 | 913 | exit++; |
el15mh | 9:960dfc71c224 | 914 | } |
el15mh | 9:960dfc71c224 | 915 | |
el15mh | 9:960dfc71c224 | 916 | break; |
el15mh | 9:960dfc71c224 | 917 | |
el15mh | 9:960dfc71c224 | 918 | case 4: |
el15mh | 9:960dfc71c224 | 919 | |
el15mh | 9:960dfc71c224 | 920 | lcd.clear(); |
el15mh | 9:960dfc71c224 | 921 | lcd.printString(" Easy", 0, 1); |
el15mh | 9:960dfc71c224 | 922 | lcd.printString(" Medium", 0, 2); |
el15mh | 9:960dfc71c224 | 923 | lcd.printString(" Hard", 0, 3); |
el15mh | 9:960dfc71c224 | 924 | lcd.printString(">Extreme", 0, 4); |
el15mh | 9:960dfc71c224 | 925 | lcd.refresh(); |
el15mh | 9:960dfc71c224 | 926 | |
el15mh | 9:960dfc71c224 | 927 | |
el15mh | 9:960dfc71c224 | 928 | wait_ms(250); // 250ms propogation delay |
el15mh | 9:960dfc71c224 | 929 | |
el15mh | 9:960dfc71c224 | 930 | if ((pad.check_event(Gamepad::A_PRESSED) || |
el15mh | 9:960dfc71c224 | 931 | pad.check_event(Gamepad::JOY_PRESSED)) || |
el15mh | 9:960dfc71c224 | 932 | (d == E)) { |
el15mh | 9:960dfc71c224 | 933 | |
el15mh | 9:960dfc71c224 | 934 | _difficulty = 4; |
el15mh | 9:960dfc71c224 | 935 | |
el15mh | 9:960dfc71c224 | 936 | if (_tone){ |
el15mh | 9:960dfc71c224 | 937 | pad.tone(C_NOTE, 0.20); |
el15mh | 9:960dfc71c224 | 938 | } |
el15mh | 9:960dfc71c224 | 939 | |
el15mh | 9:960dfc71c224 | 940 | lcd.clear(); |
el15mh | 9:960dfc71c224 | 941 | lcd.printString(" EXTREME ", 0, 1); |
el15mh | 9:960dfc71c224 | 942 | lcd.printString(" MODE", 0, 2); |
el15mh | 9:960dfc71c224 | 943 | lcd.refresh(); |
el15mh | 9:960dfc71c224 | 944 | wait(2); |
el15mh | 9:960dfc71c224 | 945 | |
el15mh | 9:960dfc71c224 | 946 | exit++; |
el15mh | 9:960dfc71c224 | 947 | } |
el15mh | 9:960dfc71c224 | 948 | |
el15mh | 9:960dfc71c224 | 949 | break; |
el15mh | 9:960dfc71c224 | 950 | |
el15mh | 9:960dfc71c224 | 951 | default: |
el15mh | 9:960dfc71c224 | 952 | |
el15mh | 9:960dfc71c224 | 953 | selected = 1; |
el15mh | 9:960dfc71c224 | 954 | |
el15mh | 9:960dfc71c224 | 955 | break; |
el15mh | 9:960dfc71c224 | 956 | |
el15mh | 9:960dfc71c224 | 957 | } |
el15mh | 9:960dfc71c224 | 958 | |
el15mh | 9:960dfc71c224 | 959 | if ((pad.check_event(Gamepad::BACK_PRESSED)) || |
el15mh | 9:960dfc71c224 | 960 | (d == W)){ |
el15mh | 9:960dfc71c224 | 961 | |
el15mh | 9:960dfc71c224 | 962 | exit++; |
el15mh | 9:960dfc71c224 | 963 | } |
el15mh | 9:960dfc71c224 | 964 | } |
el15mh | 9:960dfc71c224 | 965 | } |
el15mh | 9:960dfc71c224 | 966 | |
el15mh | 9:960dfc71c224 | 967 | /** |
el15mh | 9:960dfc71c224 | 968 | * @details - Ball colour function to select the style of ball used in the game. |
el15mh | 9:960dfc71c224 | 969 | */ |
el15mh | 9:960dfc71c224 | 970 | void Menu::ballColourOptions(N5110 &lcd, Gamepad &pad, Animations &animate) |
el15mh | 9:960dfc71c224 | 971 | { |
el15mh | 9:960dfc71c224 | 972 | int selected = 0; |
el15mh | 9:960dfc71c224 | 973 | int exit = 0; |
el15mh | 9:960dfc71c224 | 974 | wait_ms(250); |
el15mh | 9:960dfc71c224 | 975 | |
el15mh | 9:960dfc71c224 | 976 | while(exit == 0){ |
el15mh | 9:960dfc71c224 | 977 | |
el15mh | 9:960dfc71c224 | 978 | char d = pad.get_direction(); |
el15mh | 9:960dfc71c224 | 979 | |
el15mh | 9:960dfc71c224 | 980 | if ((d == NW) || |
el15mh | 9:960dfc71c224 | 981 | (d == N) || |
el15mh | 9:960dfc71c224 | 982 | (d == NE)){ |
el15mh | 9:960dfc71c224 | 983 | |
el15mh | 9:960dfc71c224 | 984 | if (_tone){ |
el15mh | 9:960dfc71c224 | 985 | pad.tone(G_NOTE, 0.20); |
el15mh | 9:960dfc71c224 | 986 | } |
el15mh | 9:960dfc71c224 | 987 | selected -= 1; |
el15mh | 9:960dfc71c224 | 988 | } |
el15mh | 9:960dfc71c224 | 989 | |
el15mh | 9:960dfc71c224 | 990 | if ((d == SW) || |
el15mh | 9:960dfc71c224 | 991 | (d == S) || |
el15mh | 9:960dfc71c224 | 992 | (d == SE)){ |
el15mh | 9:960dfc71c224 | 993 | |
el15mh | 9:960dfc71c224 | 994 | if (_tone){ |
el15mh | 9:960dfc71c224 | 995 | pad.tone(G_NOTE, 0.20); |
el15mh | 9:960dfc71c224 | 996 | } |
el15mh | 9:960dfc71c224 | 997 | selected += 1; |
el15mh | 9:960dfc71c224 | 998 | } |
el15mh | 9:960dfc71c224 | 999 | |
el15mh | 9:960dfc71c224 | 1000 | switch(selected){ |
el15mh | 9:960dfc71c224 | 1001 | |
el15mh | 9:960dfc71c224 | 1002 | case 1: |
el15mh | 9:960dfc71c224 | 1003 | |
el15mh | 9:960dfc71c224 | 1004 | // printf("case 2.1"); |
el15mh | 9:960dfc71c224 | 1005 | |
el15mh | 9:960dfc71c224 | 1006 | lcd.clear(); |
el15mh | 9:960dfc71c224 | 1007 | lcd.printString("Ball colour: ", 0, 0); |
el15mh | 9:960dfc71c224 | 1008 | lcd.printString(">Outline", 0, 2); |
el15mh | 9:960dfc71c224 | 1009 | lcd.printString(" Solid", 0, 3); |
el15mh | 9:960dfc71c224 | 1010 | lcd.refresh(); |
el15mh | 9:960dfc71c224 | 1011 | |
el15mh | 9:960dfc71c224 | 1012 | wait_ms(250); // 250ms propogation delay |
el15mh | 9:960dfc71c224 | 1013 | |
el15mh | 9:960dfc71c224 | 1014 | if ((pad.check_event(Gamepad::A_PRESSED) || |
el15mh | 9:960dfc71c224 | 1015 | pad.check_event(Gamepad::JOY_PRESSED)) || |
el15mh | 9:960dfc71c224 | 1016 | (d == E)) { |
el15mh | 9:960dfc71c224 | 1017 | |
el15mh | 9:960dfc71c224 | 1018 | if (_tone){ |
el15mh | 9:960dfc71c224 | 1019 | pad.tone(C_NOTE, 0.20); |
el15mh | 9:960dfc71c224 | 1020 | } |
el15mh | 9:960dfc71c224 | 1021 | |
el15mh | 9:960dfc71c224 | 1022 | _colour = true; // true colour => outline |
el15mh | 9:960dfc71c224 | 1023 | animate.rollingEmptyBall(lcd); |
el15mh | 9:960dfc71c224 | 1024 | exit++; |
el15mh | 9:960dfc71c224 | 1025 | } |
el15mh | 9:960dfc71c224 | 1026 | |
el15mh | 9:960dfc71c224 | 1027 | break; |
el15mh | 9:960dfc71c224 | 1028 | |
el15mh | 9:960dfc71c224 | 1029 | case 2: |
el15mh | 9:960dfc71c224 | 1030 | |
el15mh | 9:960dfc71c224 | 1031 | // printf("case 2.2"); |
el15mh | 9:960dfc71c224 | 1032 | |
el15mh | 9:960dfc71c224 | 1033 | lcd.clear(); |
el15mh | 9:960dfc71c224 | 1034 | lcd.printString("Ball colour: ", 0, 0); |
el15mh | 9:960dfc71c224 | 1035 | lcd.printString(" Outline", 0, 2); |
el15mh | 9:960dfc71c224 | 1036 | lcd.printString(">Solid", 0, 3); |
el15mh | 9:960dfc71c224 | 1037 | lcd.refresh(); |
el15mh | 9:960dfc71c224 | 1038 | |
el15mh | 9:960dfc71c224 | 1039 | wait_ms(250); // 250ms propogation delay |
el15mh | 9:960dfc71c224 | 1040 | |
el15mh | 9:960dfc71c224 | 1041 | |
el15mh | 9:960dfc71c224 | 1042 | if ((pad.check_event(Gamepad::A_PRESSED) || |
el15mh | 9:960dfc71c224 | 1043 | pad.check_event(Gamepad::JOY_PRESSED)) || |
el15mh | 9:960dfc71c224 | 1044 | (d == E)) { |
el15mh | 9:960dfc71c224 | 1045 | |
el15mh | 9:960dfc71c224 | 1046 | if (_tone){ |
el15mh | 9:960dfc71c224 | 1047 | pad.tone(C_NOTE, 0.20); |
el15mh | 9:960dfc71c224 | 1048 | } |
el15mh | 9:960dfc71c224 | 1049 | |
el15mh | 9:960dfc71c224 | 1050 | _colour = false; // false colour => solid |
el15mh | 9:960dfc71c224 | 1051 | animate.rollingSolidBall(lcd); |
el15mh | 9:960dfc71c224 | 1052 | exit++; |
el15mh | 9:960dfc71c224 | 1053 | } |
el15mh | 9:960dfc71c224 | 1054 | |
el15mh | 9:960dfc71c224 | 1055 | break; |
el15mh | 9:960dfc71c224 | 1056 | |
el15mh | 9:960dfc71c224 | 1057 | default: |
el15mh | 9:960dfc71c224 | 1058 | |
el15mh | 9:960dfc71c224 | 1059 | selected = 1; |
el15mh | 9:960dfc71c224 | 1060 | |
el15mh | 9:960dfc71c224 | 1061 | break; |
el15mh | 9:960dfc71c224 | 1062 | } |
el15mh | 9:960dfc71c224 | 1063 | |
el15mh | 9:960dfc71c224 | 1064 | if ((pad.check_event(Gamepad::BACK_PRESSED)) || |
el15mh | 9:960dfc71c224 | 1065 | (d == W)){ |
el15mh | 9:960dfc71c224 | 1066 | |
el15mh | 9:960dfc71c224 | 1067 | exit++; |
el15mh | 9:960dfc71c224 | 1068 | } |
el15mh | 9:960dfc71c224 | 1069 | } |
el15mh | 9:960dfc71c224 | 1070 | |
el15mh | 9:960dfc71c224 | 1071 | |
el15mh | 9:960dfc71c224 | 1072 | } |
el15mh | 9:960dfc71c224 | 1073 | |
el15mh | 9:960dfc71c224 | 1074 | /** |
el15mh | 9:960dfc71c224 | 1075 | * @details - LCD Inverse Colour function which allows user to switch colours on the LCD. |
el15mh | 9:960dfc71c224 | 1076 | */ |
el15mh | 9:960dfc71c224 | 1077 | void Menu::lcdInverseColour(N5110 &lcd, Gamepad &pad) |
el15mh | 9:960dfc71c224 | 1078 | { |
el15mh | 9:960dfc71c224 | 1079 | int exit = 0; |
el15mh | 9:960dfc71c224 | 1080 | |
el15mh | 9:960dfc71c224 | 1081 | while (exit == 0) { |
el15mh | 9:960dfc71c224 | 1082 | |
el15mh | 9:960dfc71c224 | 1083 | lcd.clear(); |
el15mh | 9:960dfc71c224 | 1084 | lcd.printString("Press A to", 0, 0); |
el15mh | 9:960dfc71c224 | 1085 | lcd.printString("invert colours", 0, 1); |
el15mh | 9:960dfc71c224 | 1086 | lcd.printString("Press B to", 0, 3); |
el15mh | 9:960dfc71c224 | 1087 | lcd.printString("revert to", 0, 4); |
el15mh | 9:960dfc71c224 | 1088 | lcd.printString("normal", 0, 5); |
el15mh | 9:960dfc71c224 | 1089 | |
el15mh | 9:960dfc71c224 | 1090 | if (pad.check_event(Gamepad::A_PRESSED)){ |
el15mh | 9:960dfc71c224 | 1091 | |
el15mh | 9:960dfc71c224 | 1092 | lcd.inverseMode(); |
el15mh | 9:960dfc71c224 | 1093 | if (_tone){ |
el15mh | 9:960dfc71c224 | 1094 | pad.tone(G_NOTE, 0.20); |
el15mh | 9:960dfc71c224 | 1095 | } |
el15mh | 9:960dfc71c224 | 1096 | |
el15mh | 9:960dfc71c224 | 1097 | } |
el15mh | 9:960dfc71c224 | 1098 | |
el15mh | 9:960dfc71c224 | 1099 | if (pad.check_event(Gamepad::B_PRESSED)){ |
el15mh | 9:960dfc71c224 | 1100 | |
el15mh | 9:960dfc71c224 | 1101 | lcd.normalMode(); |
el15mh | 9:960dfc71c224 | 1102 | |
el15mh | 9:960dfc71c224 | 1103 | if (_tone){ |
el15mh | 9:960dfc71c224 | 1104 | pad.tone(G_NOTE, 0.20); |
el15mh | 9:960dfc71c224 | 1105 | } |
el15mh | 9:960dfc71c224 | 1106 | } |
el15mh | 9:960dfc71c224 | 1107 | |
el15mh | 9:960dfc71c224 | 1108 | lcd.refresh(); |
el15mh | 9:960dfc71c224 | 1109 | |
el15mh | 9:960dfc71c224 | 1110 | char d = pad.get_direction(); |
el15mh | 9:960dfc71c224 | 1111 | |
el15mh | 9:960dfc71c224 | 1112 | if ((pad.check_event(Gamepad::BACK_PRESSED)) || |
el15mh | 9:960dfc71c224 | 1113 | (d == W)){ |
el15mh | 9:960dfc71c224 | 1114 | |
el15mh | 9:960dfc71c224 | 1115 | exit++; |
el15mh | 9:960dfc71c224 | 1116 | } |
el15mh | 9:960dfc71c224 | 1117 | } |
el15mh | 9:960dfc71c224 | 1118 | |
el15mh | 9:960dfc71c224 | 1119 | |
el15mh | 9:960dfc71c224 | 1120 | } |
el15mh | 9:960dfc71c224 | 1121 | |
el15mh | 9:960dfc71c224 | 1122 | /** |
el15mh | 9:960dfc71c224 | 1123 | * @details - LCD Inverse Colour function which changes the PWM value of the LCD backlight LED. |
el15mh | 9:960dfc71c224 | 1124 | */ |
el15mh | 9:960dfc71c224 | 1125 | void Menu::lcdBackgroundColour(N5110 &lcd, Gamepad &pad, Animations &animate) |
el15mh | 9:960dfc71c224 | 1126 | { |
el15mh | 9:960dfc71c224 | 1127 | // method to change the brightness of the LED backlight |
el15mh | 9:960dfc71c224 | 1128 | int exit = 0; |
el15mh | 9:960dfc71c224 | 1129 | |
el15mh | 9:960dfc71c224 | 1130 | while (exit == 0) { |
el15mh | 9:960dfc71c224 | 1131 | |
el15mh | 9:960dfc71c224 | 1132 | lcd.clear(); |
el15mh | 9:960dfc71c224 | 1133 | lcd.printString("BRIGHTNESS", 0, 0); |
el15mh | 9:960dfc71c224 | 1134 | lcd.printString("Use DIAL --->", 0, 1); |
el15mh | 9:960dfc71c224 | 1135 | lcd.printString("to adjust", 0, 2); |
el15mh | 9:960dfc71c224 | 1136 | |
el15mh | 9:960dfc71c224 | 1137 | double brightness = pad.read_pot(); // returns value between 0.0 - 1.0 |
el15mh | 9:960dfc71c224 | 1138 | |
el15mh | 9:960dfc71c224 | 1139 | lcd.setBrightness(brightness); |
el15mh | 9:960dfc71c224 | 1140 | |
el15mh | 9:960dfc71c224 | 1141 | lcd.drawRect(10, 30, 41, 8, FILL_TRANSPARENT); |
el15mh | 9:960dfc71c224 | 1142 | lcd.drawRect(11, 31, brightness * 40, 6, FILL_BLACK); |
el15mh | 9:960dfc71c224 | 1143 | lcd.refresh(); |
el15mh | 9:960dfc71c224 | 1144 | |
el15mh | 9:960dfc71c224 | 1145 | // animate.brightnessBar(lcd, brightness); |
el15mh | 9:960dfc71c224 | 1146 | lcd.refresh(); |
el15mh | 9:960dfc71c224 | 1147 | |
el15mh | 9:960dfc71c224 | 1148 | wait_ms(5); |
el15mh | 9:960dfc71c224 | 1149 | |
el15mh | 9:960dfc71c224 | 1150 | char d = pad.get_direction(); |
el15mh | 9:960dfc71c224 | 1151 | |
el15mh | 9:960dfc71c224 | 1152 | if ((pad.check_event(Gamepad::BACK_PRESSED)) || |
el15mh | 9:960dfc71c224 | 1153 | (d == W)){ |
el15mh | 9:960dfc71c224 | 1154 | |
el15mh | 9:960dfc71c224 | 1155 | if (_tone){ |
el15mh | 9:960dfc71c224 | 1156 | pad.tone(G_NOTE, 0.20); |
el15mh | 9:960dfc71c224 | 1157 | } |
el15mh | 9:960dfc71c224 | 1158 | exit++; |
el15mh | 9:960dfc71c224 | 1159 | } |
el15mh | 9:960dfc71c224 | 1160 | } |
el15mh | 9:960dfc71c224 | 1161 | } |
el15mh | 9:960dfc71c224 | 1162 | |
el15mh | 9:960dfc71c224 | 1163 | /** |
el15mh | 9:960dfc71c224 | 1164 | * @details - Game Speed function which changes the FPS used in the game loop. |
el15mh | 9:960dfc71c224 | 1165 | */ |
el15mh | 9:960dfc71c224 | 1166 | void Menu::speedSettings(N5110 &lcd, Gamepad &pad) |
el15mh | 9:960dfc71c224 | 1167 | { |
el15mh | 9:960dfc71c224 | 1168 | int exit = 0; |
el15mh | 9:960dfc71c224 | 1169 | |
el15mh | 9:960dfc71c224 | 1170 | while (exit == 0){ |
el15mh | 9:960dfc71c224 | 1171 | |
el15mh | 9:960dfc71c224 | 1172 | lcd.clear(); |
el15mh | 9:960dfc71c224 | 1173 | lcd.printString("Use dial to ", 0, 0); |
el15mh | 9:960dfc71c224 | 1174 | lcd.printString("adjust speed", 0, 1); |
el15mh | 9:960dfc71c224 | 1175 | |
el15mh | 9:960dfc71c224 | 1176 | double speed = pad.read_pot(); // returns value between 0.0 - 1.0 |
el15mh | 9:960dfc71c224 | 1177 | |
el15mh | 9:960dfc71c224 | 1178 | // nominal value is 50 FPS, i.e speed of 0.5 |
el15mh | 9:960dfc71c224 | 1179 | // have values between 25 and 75 |
el15mh | 9:960dfc71c224 | 1180 | |
el15mh | 9:960dfc71c224 | 1181 | // pot value of 0 corresponds to FPS of 25 |
el15mh | 9:960dfc71c224 | 1182 | // pot value of 1 cooresponds to FPS of 75 |
el15mh | 9:960dfc71c224 | 1183 | |
el15mh | 9:960dfc71c224 | 1184 | // relationship between pot value and FPS: |
el15mh | 9:960dfc71c224 | 1185 | _FPS = (speed * 50) + 25; |
el15mh | 9:960dfc71c224 | 1186 | |
el15mh | 9:960dfc71c224 | 1187 | // lcd.drawRect(10, 30, 41, 8, FILL_TRANSPARENT); |
el15mh | 9:960dfc71c224 | 1188 | // lcd.drawRect(11, 31, _FPS, 6, FILL_BLACK); |
el15mh | 9:960dfc71c224 | 1189 | |
el15mh | 9:960dfc71c224 | 1190 | lcd.drawCircle(42, 31, 12, FILL_TRANSPARENT); |
el15mh | 9:960dfc71c224 | 1191 | |
el15mh | 9:960dfc71c224 | 1192 | // printf("input = %f \n", input); |
el15mh | 9:960dfc71c224 | 1193 | |
el15mh | 9:960dfc71c224 | 1194 | double x2 = 42 + (12 * sin(1.5 * 3.14159 * (speed - 0.5))); |
el15mh | 9:960dfc71c224 | 1195 | double y2 = 31 - (12 * cos(1.5 * 3.14159 * (speed - 0.5))); |
el15mh | 9:960dfc71c224 | 1196 | |
el15mh | 9:960dfc71c224 | 1197 | lcd.drawLine(42, 31, x2, y2, FILL_BLACK); |
el15mh | 9:960dfc71c224 | 1198 | |
el15mh | 9:960dfc71c224 | 1199 | lcd.refresh(); |
el15mh | 9:960dfc71c224 | 1200 | |
el15mh | 9:960dfc71c224 | 1201 | wait_ms(5); |
el15mh | 9:960dfc71c224 | 1202 | |
el15mh | 9:960dfc71c224 | 1203 | char d = pad.get_direction(); |
el15mh | 9:960dfc71c224 | 1204 | |
el15mh | 9:960dfc71c224 | 1205 | if ((pad.check_event(Gamepad::BACK_PRESSED)) || |
el15mh | 9:960dfc71c224 | 1206 | (d == W)){ |
el15mh | 9:960dfc71c224 | 1207 | |
el15mh | 9:960dfc71c224 | 1208 | if (_tone){ |
el15mh | 9:960dfc71c224 | 1209 | pad.tone(G_NOTE, 0.20); |
el15mh | 9:960dfc71c224 | 1210 | } |
el15mh | 9:960dfc71c224 | 1211 | exit++; |
el15mh | 9:960dfc71c224 | 1212 | } |
el15mh | 9:960dfc71c224 | 1213 | } |
el15mh | 9:960dfc71c224 | 1214 | } |
el15mh | 9:960dfc71c224 | 1215 | |
el15mh | 9:960dfc71c224 | 1216 | /** |
el15mh | 9:960dfc71c224 | 1217 | * @details - Animate Joystick function creats a short animation of moving joystick. |
el15mh | 9:960dfc71c224 | 1218 | */ |
el15mh | 9:960dfc71c224 | 1219 | void Menu::animateJoystick(N5110 &lcd, Animations &animate) |
el15mh | 9:960dfc71c224 | 1220 | { |
el15mh | 9:960dfc71c224 | 1221 | int timer = 0; |
el15mh | 9:960dfc71c224 | 1222 | while (timer <= 3200){ |
el15mh | 9:960dfc71c224 | 1223 | |
el15mh | 9:960dfc71c224 | 1224 | lcd.clear(); |
el15mh | 9:960dfc71c224 | 1225 | lcd.printString(" JOYSTICK ", 0, 1); |
el15mh | 9:960dfc71c224 | 1226 | lcd.printString(" SELECTED ", 0, 2); |
el15mh | 9:960dfc71c224 | 1227 | animate.drawLeftJoystick(lcd); |
el15mh | 9:960dfc71c224 | 1228 | lcd.refresh(); |
el15mh | 9:960dfc71c224 | 1229 | timer += 400; |
el15mh | 9:960dfc71c224 | 1230 | wait_ms(400); |
el15mh | 9:960dfc71c224 | 1231 | |
el15mh | 9:960dfc71c224 | 1232 | lcd.clear(); |
el15mh | 9:960dfc71c224 | 1233 | lcd.printString(" JOYSTICK ", 0, 1); |
el15mh | 9:960dfc71c224 | 1234 | lcd.printString(" SELECTED ", 0, 2); |
el15mh | 9:960dfc71c224 | 1235 | animate.drawVerticalJoystick(lcd); |
el15mh | 9:960dfc71c224 | 1236 | lcd.refresh(); |
el15mh | 9:960dfc71c224 | 1237 | timer += 400; |
el15mh | 9:960dfc71c224 | 1238 | wait_ms(400); |
el15mh | 9:960dfc71c224 | 1239 | |
el15mh | 9:960dfc71c224 | 1240 | lcd.clear(); |
el15mh | 9:960dfc71c224 | 1241 | lcd.printString(" JOYSTICK ", 0, 1); |
el15mh | 9:960dfc71c224 | 1242 | lcd.printString(" SELECTED ", 0, 2); |
el15mh | 9:960dfc71c224 | 1243 | animate.drawRightJoystick(lcd); |
el15mh | 9:960dfc71c224 | 1244 | lcd.refresh(); |
el15mh | 9:960dfc71c224 | 1245 | timer += 400; |
el15mh | 9:960dfc71c224 | 1246 | wait_ms(400); |
el15mh | 9:960dfc71c224 | 1247 | |
el15mh | 9:960dfc71c224 | 1248 | lcd.clear(); |
el15mh | 9:960dfc71c224 | 1249 | lcd.printString(" JOYSTICK ", 0, 1); |
el15mh | 9:960dfc71c224 | 1250 | lcd.printString(" SELECTED ", 0, 2); |
el15mh | 9:960dfc71c224 | 1251 | animate.drawVerticalJoystick(lcd); |
el15mh | 9:960dfc71c224 | 1252 | lcd.refresh(); |
el15mh | 9:960dfc71c224 | 1253 | timer += 400; |
el15mh | 9:960dfc71c224 | 1254 | wait_ms(400); |
el15mh | 9:960dfc71c224 | 1255 | } |
el15mh | 9:960dfc71c224 | 1256 | } |
el15mh | 9:960dfc71c224 | 1257 | |
el15mh | 9:960dfc71c224 | 1258 | /** |
el15mh | 9:960dfc71c224 | 1259 | * @details - Animate Gamepad function creats a short animation of moving gamepad. |
el15mh | 9:960dfc71c224 | 1260 | */ |
el15mh | 9:960dfc71c224 | 1261 | void Menu::animateGamepad(N5110 &lcd, Animations &animate) |
el15mh | 9:960dfc71c224 | 1262 | { |
el15mh | 9:960dfc71c224 | 1263 | int timer = 0; |
el15mh | 9:960dfc71c224 | 1264 | while (timer <= 3200){ |
el15mh | 9:960dfc71c224 | 1265 | |
el15mh | 9:960dfc71c224 | 1266 | lcd.clear(); |
el15mh | 9:960dfc71c224 | 1267 | lcd.printString(" GAMEPAD TILT ", 0, 1); |
el15mh | 9:960dfc71c224 | 1268 | lcd.printString(" SELECTED ", 0, 2); |
el15mh | 9:960dfc71c224 | 1269 | animate.drawLeftGamepad(lcd); |
el15mh | 9:960dfc71c224 | 1270 | lcd.refresh(); |
el15mh | 9:960dfc71c224 | 1271 | timer += 400; |
el15mh | 9:960dfc71c224 | 1272 | wait_ms(400); |
el15mh | 9:960dfc71c224 | 1273 | |
el15mh | 9:960dfc71c224 | 1274 | lcd.clear(); |
el15mh | 9:960dfc71c224 | 1275 | lcd.printString(" GAMEPAD TILT ", 0, 1); |
el15mh | 9:960dfc71c224 | 1276 | lcd.printString(" SELECTED ", 0, 2); |
el15mh | 9:960dfc71c224 | 1277 | animate.drawVerticalGamepad(lcd); |
el15mh | 9:960dfc71c224 | 1278 | lcd.refresh(); |
el15mh | 9:960dfc71c224 | 1279 | timer += 400; |
el15mh | 9:960dfc71c224 | 1280 | wait_ms(400); |
el15mh | 9:960dfc71c224 | 1281 | |
el15mh | 9:960dfc71c224 | 1282 | |
el15mh | 9:960dfc71c224 | 1283 | lcd.clear(); |
el15mh | 9:960dfc71c224 | 1284 | lcd.printString(" GAMEPAD TILT ", 0, 1); |
el15mh | 9:960dfc71c224 | 1285 | lcd.printString(" SELECTED ", 0, 2); |
el15mh | 9:960dfc71c224 | 1286 | animate.drawRightGamepad(lcd); |
el15mh | 9:960dfc71c224 | 1287 | lcd.refresh(); |
el15mh | 9:960dfc71c224 | 1288 | timer += 400; |
el15mh | 9:960dfc71c224 | 1289 | wait_ms(400); |
el15mh | 9:960dfc71c224 | 1290 | |
el15mh | 9:960dfc71c224 | 1291 | lcd.clear(); |
el15mh | 9:960dfc71c224 | 1292 | lcd.printString(" GAMEPAD TILT ", 0, 1); |
el15mh | 9:960dfc71c224 | 1293 | lcd.printString(" SELECTED ", 0, 2); |
el15mh | 9:960dfc71c224 | 1294 | animate.drawVerticalGamepad(lcd); |
el15mh | 9:960dfc71c224 | 1295 | lcd.refresh(); |
el15mh | 9:960dfc71c224 | 1296 | timer += 400; |
el15mh | 9:960dfc71c224 | 1297 | wait_ms(400); |
el15mh | 9:960dfc71c224 | 1298 | } |
el15mh | 9:960dfc71c224 | 1299 | } |
el15mh | 9:960dfc71c224 | 1300 | |
el15mh | 9:960dfc71c224 | 1301 | /** |
el15mh | 9:960dfc71c224 | 1302 | * @details - Animate Stickman function creates a short animation of jumping man to signify goal reached. |
el15mh | 9:960dfc71c224 | 1303 | */ |
el15mh | 9:960dfc71c224 | 1304 | void Menu::animateStickman(N5110 &lcd, Gamepad &pad, Animations &animate) |
el15mh | 9:960dfc71c224 | 1305 | { |
el15mh | 9:960dfc71c224 | 1306 | int timer = 0; |
el15mh | 9:960dfc71c224 | 1307 | while (timer <= 3200){ |
el15mh | 9:960dfc71c224 | 1308 | |
el15mh | 9:960dfc71c224 | 1309 | int delay = 60; |
el15mh | 9:960dfc71c224 | 1310 | |
el15mh | 9:960dfc71c224 | 1311 | lcd.clear(); |
el15mh | 9:960dfc71c224 | 1312 | animate.stickmanOne(lcd); |
el15mh | 9:960dfc71c224 | 1313 | pad.leds_on(); |
el15mh | 9:960dfc71c224 | 1314 | lcd.refresh(); |
el15mh | 9:960dfc71c224 | 1315 | timer += delay; |
el15mh | 9:960dfc71c224 | 1316 | wait_ms(delay); |
el15mh | 9:960dfc71c224 | 1317 | |
el15mh | 9:960dfc71c224 | 1318 | lcd.clear(); |
el15mh | 9:960dfc71c224 | 1319 | animate.stickmanTwo(lcd); |
el15mh | 9:960dfc71c224 | 1320 | pad.leds_off(); |
el15mh | 9:960dfc71c224 | 1321 | lcd.refresh(); |
el15mh | 9:960dfc71c224 | 1322 | timer += delay; |
el15mh | 9:960dfc71c224 | 1323 | wait_ms(delay); |
el15mh | 9:960dfc71c224 | 1324 | |
el15mh | 9:960dfc71c224 | 1325 | lcd.clear(); |
el15mh | 9:960dfc71c224 | 1326 | animate.stickmanThree(lcd); |
el15mh | 9:960dfc71c224 | 1327 | pad.leds_on(); |
el15mh | 9:960dfc71c224 | 1328 | lcd.refresh(); |
el15mh | 9:960dfc71c224 | 1329 | timer += delay; |
el15mh | 9:960dfc71c224 | 1330 | wait_ms(delay); |
el15mh | 9:960dfc71c224 | 1331 | |
el15mh | 9:960dfc71c224 | 1332 | lcd.clear(); |
el15mh | 9:960dfc71c224 | 1333 | animate.stickmanFour(lcd); |
el15mh | 9:960dfc71c224 | 1334 | pad.leds_off(); |
el15mh | 9:960dfc71c224 | 1335 | lcd.refresh(); |
el15mh | 9:960dfc71c224 | 1336 | timer += delay; |
el15mh | 9:960dfc71c224 | 1337 | wait_ms(delay); |
el15mh | 9:960dfc71c224 | 1338 | |
el15mh | 9:960dfc71c224 | 1339 | lcd.clear(); |
el15mh | 9:960dfc71c224 | 1340 | animate.stickmanFive(lcd); |
el15mh | 9:960dfc71c224 | 1341 | pad.leds_on(); |
el15mh | 9:960dfc71c224 | 1342 | lcd.refresh(); |
el15mh | 9:960dfc71c224 | 1343 | timer += delay; |
el15mh | 9:960dfc71c224 | 1344 | wait_ms(delay); |
el15mh | 9:960dfc71c224 | 1345 | |
el15mh | 9:960dfc71c224 | 1346 | lcd.clear(); |
el15mh | 9:960dfc71c224 | 1347 | animate.stickmanSix(lcd); |
el15mh | 9:960dfc71c224 | 1348 | pad.leds_off(); |
el15mh | 9:960dfc71c224 | 1349 | lcd.refresh(); |
el15mh | 9:960dfc71c224 | 1350 | timer += delay; |
el15mh | 9:960dfc71c224 | 1351 | wait_ms(delay); |
el15mh | 9:960dfc71c224 | 1352 | |
el15mh | 9:960dfc71c224 | 1353 | lcd.clear(); |
el15mh | 9:960dfc71c224 | 1354 | animate.stickmanFive(lcd); |
el15mh | 9:960dfc71c224 | 1355 | pad.leds_on(); |
el15mh | 9:960dfc71c224 | 1356 | lcd.refresh(); |
el15mh | 9:960dfc71c224 | 1357 | timer += delay; |
el15mh | 9:960dfc71c224 | 1358 | wait_ms(delay); |
el15mh | 9:960dfc71c224 | 1359 | |
el15mh | 9:960dfc71c224 | 1360 | lcd.clear(); |
el15mh | 9:960dfc71c224 | 1361 | animate.stickmanFour(lcd); |
el15mh | 9:960dfc71c224 | 1362 | pad.leds_off(); |
el15mh | 9:960dfc71c224 | 1363 | lcd.refresh(); |
el15mh | 9:960dfc71c224 | 1364 | timer += delay; |
el15mh | 9:960dfc71c224 | 1365 | wait_ms(delay); |
el15mh | 9:960dfc71c224 | 1366 | |
el15mh | 9:960dfc71c224 | 1367 | lcd.clear(); |
el15mh | 9:960dfc71c224 | 1368 | animate.stickmanThree(lcd); |
el15mh | 9:960dfc71c224 | 1369 | pad.leds_on(); |
el15mh | 9:960dfc71c224 | 1370 | lcd.refresh(); |
el15mh | 9:960dfc71c224 | 1371 | timer += delay; |
el15mh | 9:960dfc71c224 | 1372 | wait_ms(delay); |
el15mh | 9:960dfc71c224 | 1373 | |
el15mh | 9:960dfc71c224 | 1374 | lcd.clear(); |
el15mh | 9:960dfc71c224 | 1375 | animate.stickmanTwo(lcd); |
el15mh | 9:960dfc71c224 | 1376 | pad.leds_off(); |
el15mh | 9:960dfc71c224 | 1377 | lcd.refresh(); |
el15mh | 9:960dfc71c224 | 1378 | timer += delay; |
el15mh | 9:960dfc71c224 | 1379 | wait_ms(delay); |
el15mh | 9:960dfc71c224 | 1380 | |
el15mh | 9:960dfc71c224 | 1381 | } |
el15mh | 9:960dfc71c224 | 1382 | |
el15mh | 9:960dfc71c224 | 1383 | } |
el15mh | 9:960dfc71c224 | 1384 | |
el15mh | 9:960dfc71c224 | 1385 |