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