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