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