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