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.

Committer:
el15mh
Date:
Fri Apr 07 10:28:49 2017 +0000
Revision:
2:917211a4551b
Parent:
1:21b7a5edb9c2
Child:
3:a79daa7c2b55
whole program basic with menu interface

Who changed what in which revision?

UserRevisionLine numberNew 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 2:917211a4551b 24 void Menu::init(int mazeIndex)
el15mh 2:917211a4551b 25 {
el15mh 2:917211a4551b 26 _mazeIndex = mazeIndex;
el15mh 2:917211a4551b 27
el15mh 2:917211a4551b 28 _engine.init(_mazeIndex, 4, 4, 4);
el15mh 2:917211a4551b 29
el15mh 2:917211a4551b 30 /*
el15mh 2:917211a4551b 31 if ((_mazeIndex == 0) ||
el15mh 2:917211a4551b 32 (_mazeIndex == 1)) {
el15mh 2:917211a4551b 33
el15mh 2:917211a4551b 34 _engine.init(_mazeIndex, 4, 4, 4);
el15mh 2:917211a4551b 35 }
el15mh 2:917211a4551b 36
el15mh 2:917211a4551b 37 else {
el15mh 2:917211a4551b 38 _engine.init(_mazeIndex, 2, 2, 2);
el15mh 2:917211a4551b 39 }
el15mh 2:917211a4551b 40 */
el15mh 2:917211a4551b 41 }
el15mh 2:917211a4551b 42
el15mh 2:917211a4551b 43 /// MAIN MENU METHOD ///
el15mh 2:917211a4551b 44
el15mh 2:917211a4551b 45 void Menu::main(N5110 &lcd, Gamepad &pad, FXOS8700CQ &device)
el15mh 0:b32f6570a26d 46 {
el15mh 0:b32f6570a26d 47 int selected = 0;
el15mh 0:b32f6570a26d 48
el15mh 0:b32f6570a26d 49 while(1) {
el15mh 0:b32f6570a26d 50
el15mh 0:b32f6570a26d 51 char d = pad.get_direction();
el15mh 0:b32f6570a26d 52
el15mh 0:b32f6570a26d 53 if ((d == NW) ||
el15mh 0:b32f6570a26d 54 (d == N) ||
el15mh 0:b32f6570a26d 55 (d == NE)){
el15mh 0:b32f6570a26d 56
el15mh 0:b32f6570a26d 57 selected -= 1;
el15mh 0:b32f6570a26d 58 }
el15mh 0:b32f6570a26d 59
el15mh 0:b32f6570a26d 60 if ((d == SW) ||
el15mh 0:b32f6570a26d 61 (d == S) ||
el15mh 0:b32f6570a26d 62 (d == SE)){
el15mh 0:b32f6570a26d 63
el15mh 0:b32f6570a26d 64 selected += 1;
el15mh 0:b32f6570a26d 65 }
el15mh 0:b32f6570a26d 66
el15mh 1:21b7a5edb9c2 67 // lcd.printString("Testing", 0, 2);
el15mh 1:21b7a5edb9c2 68 switch (selected) {
el15mh 1:21b7a5edb9c2 69
el15mh 1:21b7a5edb9c2 70 case 1:
el15mh 1:21b7a5edb9c2 71
el15mh 1:21b7a5edb9c2 72 lcd.clear();
el15mh 1:21b7a5edb9c2 73 lcd.printString(">Play game", 0, 0);
el15mh 1:21b7a5edb9c2 74 lcd.printString(" Game options", 0, 1);
el15mh 1:21b7a5edb9c2 75 lcd.printString(" LCD settings", 0, 2);
el15mh 1:21b7a5edb9c2 76 lcd.printString(" Sound", 0, 3);
el15mh 1:21b7a5edb9c2 77
el15mh 1:21b7a5edb9c2 78 lcd.refresh();
el15mh 1:21b7a5edb9c2 79
el15mh 1:21b7a5edb9c2 80 // either clicking joystick or pressing A selects function
el15mh 1:21b7a5edb9c2 81 if ((pad.check_event(Gamepad::A_PRESSED) ||
el15mh 1:21b7a5edb9c2 82 pad.check_event(Gamepad::JOY_PRESSED)) ||
el15mh 1:21b7a5edb9c2 83 (d == E)) {
el15mh 1:21b7a5edb9c2 84
el15mh 2:917211a4551b 85 playGame(_mazeIndex, lcd, pad, device); // call the game function
el15mh 1:21b7a5edb9c2 86 }
el15mh 1:21b7a5edb9c2 87
el15mh 1:21b7a5edb9c2 88 wait_ms(250); // 250ms propogation delay
el15mh 1:21b7a5edb9c2 89
el15mh 1:21b7a5edb9c2 90 break;
el15mh 1:21b7a5edb9c2 91
el15mh 1:21b7a5edb9c2 92 case 2:
el15mh 1:21b7a5edb9c2 93
el15mh 1:21b7a5edb9c2 94 lcd.clear();
el15mh 1:21b7a5edb9c2 95 lcd.printString(" Play game", 0, 0);
el15mh 1:21b7a5edb9c2 96 lcd.printString(">Game options", 0, 1);
el15mh 1:21b7a5edb9c2 97 lcd.printString(" LCD settings", 0, 2);
el15mh 1:21b7a5edb9c2 98 lcd.printString(" Sound", 0, 3);
el15mh 1:21b7a5edb9c2 99
el15mh 1:21b7a5edb9c2 100 lcd.refresh();
el15mh 1:21b7a5edb9c2 101
el15mh 1:21b7a5edb9c2 102
el15mh 1:21b7a5edb9c2 103 if ((pad.check_event(Gamepad::A_PRESSED) ||
el15mh 1:21b7a5edb9c2 104 pad.check_event(Gamepad::JOY_PRESSED)) ||
el15mh 1:21b7a5edb9c2 105 (d == E)) {
el15mh 1:21b7a5edb9c2 106
el15mh 1:21b7a5edb9c2 107 options(lcd, pad);
el15mh 1:21b7a5edb9c2 108 }
el15mh 1:21b7a5edb9c2 109
el15mh 1:21b7a5edb9c2 110 wait_ms(250); // 250ms propogation delay
el15mh 1:21b7a5edb9c2 111
el15mh 1:21b7a5edb9c2 112 break;
el15mh 1:21b7a5edb9c2 113
el15mh 1:21b7a5edb9c2 114 case 3:
el15mh 1:21b7a5edb9c2 115
el15mh 1:21b7a5edb9c2 116 lcd.clear();
el15mh 1:21b7a5edb9c2 117 lcd.printString(" Play game", 0, 0);
el15mh 1:21b7a5edb9c2 118 lcd.printString(" Game options", 0, 1);
el15mh 1:21b7a5edb9c2 119 lcd.printString(">LCD settings", 0, 2);
el15mh 1:21b7a5edb9c2 120 lcd.printString(" Sound", 0, 3);
el15mh 1:21b7a5edb9c2 121
el15mh 1:21b7a5edb9c2 122 lcd.refresh();
el15mh 1:21b7a5edb9c2 123
el15mh 1:21b7a5edb9c2 124
el15mh 1:21b7a5edb9c2 125 if ((pad.check_event(Gamepad::A_PRESSED) ||
el15mh 1:21b7a5edb9c2 126 pad.check_event(Gamepad::JOY_PRESSED)) ||
el15mh 1:21b7a5edb9c2 127 (d == E)) {
el15mh 1:21b7a5edb9c2 128
el15mh 1:21b7a5edb9c2 129 lcdSettings(lcd, pad);
el15mh 1:21b7a5edb9c2 130 }
el15mh 1:21b7a5edb9c2 131
el15mh 1:21b7a5edb9c2 132 wait_ms(250); // 250ms propogation delay
el15mh 1:21b7a5edb9c2 133
el15mh 1:21b7a5edb9c2 134 break;
el15mh 1:21b7a5edb9c2 135
el15mh 1:21b7a5edb9c2 136 case 4:
el15mh 1:21b7a5edb9c2 137
el15mh 1:21b7a5edb9c2 138 lcd.clear();
el15mh 1:21b7a5edb9c2 139 lcd.printString(" Play game", 0, 0);
el15mh 1:21b7a5edb9c2 140 lcd.printString(" Game options", 0, 1);
el15mh 1:21b7a5edb9c2 141 lcd.printString(" LCD settings", 0, 2);
el15mh 1:21b7a5edb9c2 142 lcd.printString(">Sound", 0, 3);
el15mh 1:21b7a5edb9c2 143
el15mh 1:21b7a5edb9c2 144 lcd.refresh();
el15mh 1:21b7a5edb9c2 145
el15mh 1:21b7a5edb9c2 146
el15mh 1:21b7a5edb9c2 147 if ((pad.check_event(Gamepad::A_PRESSED) ||
el15mh 1:21b7a5edb9c2 148 pad.check_event(Gamepad::JOY_PRESSED)) ||
el15mh 1:21b7a5edb9c2 149 (d == E)) {
el15mh 1:21b7a5edb9c2 150
el15mh 1:21b7a5edb9c2 151 soundSettings(lcd, pad);
el15mh 1:21b7a5edb9c2 152 }
el15mh 1:21b7a5edb9c2 153
el15mh 1:21b7a5edb9c2 154 wait_ms(250); // 250ms propogation delay
el15mh 1:21b7a5edb9c2 155
el15mh 1:21b7a5edb9c2 156 break;
el15mh 1:21b7a5edb9c2 157
el15mh 1:21b7a5edb9c2 158 default:
el15mh 1:21b7a5edb9c2 159
el15mh 1:21b7a5edb9c2 160 selected = 1;
el15mh 1:21b7a5edb9c2 161
el15mh 1:21b7a5edb9c2 162 break;
el15mh 1:21b7a5edb9c2 163 }
el15mh 1:21b7a5edb9c2 164
el15mh 0:b32f6570a26d 165 // printf("Joystick position = %c \n", d);
el15mh 0:b32f6570a26d 166 // printf("Selected = %i \n", selected);
el15mh 0:b32f6570a26d 167
el15mh 0:b32f6570a26d 168 }
el15mh 0:b32f6570a26d 169 }
el15mh 0:b32f6570a26d 170
el15mh 2:917211a4551b 171 /// INTRO LOOP ///
el15mh 2:917211a4551b 172
el15mh 2:917211a4551b 173 void intro(N5110 &lcd, Gamepad &pad)
el15mh 2:917211a4551b 174 {
el15mh 2:917211a4551b 175
el15mh 2:917211a4551b 176 // printf("intro started \n");
el15mh 2:917211a4551b 177 while (pad.check_event(Gamepad::START_PRESSED) == false){
el15mh 2:917211a4551b 178
el15mh 2:917211a4551b 179 // animation sequence
el15mh 2:917211a4551b 180 // lcd.drawCircle(x, y, radius, type);
el15mh 2:917211a4551b 181
el15mh 2:917211a4551b 182 // DRAW FIRST SEQUENCE OF CIRLCES MOVING ACROSS LCD //
el15mh 2:917211a4551b 183 for (int i = 0; i < 61; i++){
el15mh 2:917211a4551b 184
el15mh 2:917211a4551b 185 lcd.clear();
el15mh 2:917211a4551b 186 lcd.printString(" Welcome to ", 0, 1);
el15mh 2:917211a4551b 187 lcd.printString(" Roller Maze ", 0, 2);
el15mh 2:917211a4551b 188 // printf("loop \n");
el15mh 2:917211a4551b 189 lcd.drawLine(56, 40, 68, 40, FILL_BLACK);
el15mh 2:917211a4551b 190 lcd.drawLine(56, 41, 68, 41, FILL_BLACK);
el15mh 2:917211a4551b 191 lcd.refresh();
el15mh 2:917211a4551b 192
el15mh 2:917211a4551b 193 if (i < 57){
el15mh 2:917211a4551b 194 lcd.drawCircle(i, 36, 4, FILL_BLACK);
el15mh 2:917211a4551b 195 lcd.refresh();
el15mh 2:917211a4551b 196 wait_ms(50);
el15mh 2:917211a4551b 197
el15mh 2:917211a4551b 198 }
el15mh 2:917211a4551b 199
el15mh 2:917211a4551b 200 else if (i == 57){
el15mh 2:917211a4551b 201
el15mh 2:917211a4551b 202 lcd.clear();
el15mh 2:917211a4551b 203 lcd.printString(" Welcome to ", 0, 1);
el15mh 2:917211a4551b 204 lcd.printString(" Roller Maze ", 0, 2);
el15mh 2:917211a4551b 205 // printf("loop \n");
el15mh 2:917211a4551b 206 lcd.drawLine(56, 40, 68, 40, FILL_BLACK);
el15mh 2:917211a4551b 207 lcd.drawLine(56, 41, 68, 41, FILL_BLACK);
el15mh 2:917211a4551b 208 lcd.drawCircle(i, 37, 4, FILL_BLACK);
el15mh 2:917211a4551b 209
el15mh 2:917211a4551b 210 wait_ms(25);
el15mh 2:917211a4551b 211
el15mh 2:917211a4551b 212 for (int c = 55; c < 68; c++){
el15mh 2:917211a4551b 213 for (int d = 42; d < 47; d++){
el15mh 2:917211a4551b 214
el15mh 2:917211a4551b 215 lcd.clearPixel(c, 42);
el15mh 2:917211a4551b 216 lcd.clearPixel(c, 43);
el15mh 2:917211a4551b 217 lcd.clearPixel(c, 44);
el15mh 2:917211a4551b 218 lcd.clearPixel(c, 45);
el15mh 2:917211a4551b 219 lcd.clearPixel(c, 46);
el15mh 2:917211a4551b 220 lcd.clearPixel(c, 47);
el15mh 2:917211a4551b 221 lcd.refresh();
el15mh 2:917211a4551b 222
el15mh 2:917211a4551b 223 }
el15mh 2:917211a4551b 224 }
el15mh 2:917211a4551b 225
el15mh 2:917211a4551b 226 lcd.refresh();
el15mh 2:917211a4551b 227 }
el15mh 2:917211a4551b 228 else if (i == 58){
el15mh 2:917211a4551b 229
el15mh 2:917211a4551b 230 lcd.clear();
el15mh 2:917211a4551b 231 lcd.printString(" Welcome to ", 0, 1);
el15mh 2:917211a4551b 232 lcd.printString(" Roller Maze ", 0, 2);
el15mh 2:917211a4551b 233 // printf("loop \n");
el15mh 2:917211a4551b 234 lcd.drawLine(56, 40, 68, 40, FILL_BLACK);
el15mh 2:917211a4551b 235 lcd.drawLine(56, 41, 68, 41, FILL_BLACK);
el15mh 2:917211a4551b 236 lcd.drawCircle(i, 38, 4, FILL_BLACK);
el15mh 2:917211a4551b 237
el15mh 2:917211a4551b 238 wait_ms(25);
el15mh 2:917211a4551b 239
el15mh 2:917211a4551b 240 for (int c = 55; c < 68; c++){
el15mh 2:917211a4551b 241 for (int d = 42; d < 47; d++){
el15mh 2:917211a4551b 242
el15mh 2:917211a4551b 243 lcd.clearPixel(c, 42);
el15mh 2:917211a4551b 244 lcd.clearPixel(c, 43);
el15mh 2:917211a4551b 245 lcd.clearPixel(c, 44);
el15mh 2:917211a4551b 246 lcd.clearPixel(c, 45);
el15mh 2:917211a4551b 247 lcd.clearPixel(c, 46);
el15mh 2:917211a4551b 248 lcd.clearPixel(c, 47);
el15mh 2:917211a4551b 249 lcd.refresh();
el15mh 2:917211a4551b 250
el15mh 2:917211a4551b 251 }
el15mh 2:917211a4551b 252 }
el15mh 2:917211a4551b 253
el15mh 2:917211a4551b 254 lcd.refresh();
el15mh 2:917211a4551b 255
el15mh 2:917211a4551b 256 }
el15mh 2:917211a4551b 257 else if (i == 59){
el15mh 2:917211a4551b 258
el15mh 2:917211a4551b 259 lcd.clear();
el15mh 2:917211a4551b 260 lcd.printString(" Welcome to ", 0, 1);
el15mh 2:917211a4551b 261 lcd.printString(" Roller Maze ", 0, 2);
el15mh 2:917211a4551b 262 // printf("loop \n");
el15mh 2:917211a4551b 263 lcd.drawLine(56, 40, 68, 40, FILL_BLACK);
el15mh 2:917211a4551b 264 lcd.drawLine(56, 41, 68, 41, FILL_BLACK);
el15mh 2:917211a4551b 265 lcd.drawCircle(i, 39, 4, FILL_BLACK);
el15mh 2:917211a4551b 266
el15mh 2:917211a4551b 267 wait_ms(25);
el15mh 2:917211a4551b 268
el15mh 2:917211a4551b 269 for (int c = 55; c < 68; c++){
el15mh 2:917211a4551b 270 for (int d = 42; d < 47; d++){
el15mh 2:917211a4551b 271
el15mh 2:917211a4551b 272 lcd.clearPixel(c, 42);
el15mh 2:917211a4551b 273 lcd.clearPixel(c, 43);
el15mh 2:917211a4551b 274 lcd.clearPixel(c, 44);
el15mh 2:917211a4551b 275 lcd.clearPixel(c, 45);
el15mh 2:917211a4551b 276 lcd.clearPixel(c, 46);
el15mh 2:917211a4551b 277 lcd.clearPixel(c, 47);
el15mh 2:917211a4551b 278 lcd.refresh();
el15mh 2:917211a4551b 279
el15mh 2:917211a4551b 280 }
el15mh 2:917211a4551b 281 }
el15mh 2:917211a4551b 282
el15mh 2:917211a4551b 283 lcd.refresh();
el15mh 2:917211a4551b 284
el15mh 2:917211a4551b 285 }
el15mh 2:917211a4551b 286 else {
el15mh 2:917211a4551b 287
el15mh 2:917211a4551b 288 for (int j = 40; j < 48; j++){
el15mh 2:917211a4551b 289
el15mh 2:917211a4551b 290 lcd.clear();
el15mh 2:917211a4551b 291 lcd.printString(" Welcome to ", 0, 1);
el15mh 2:917211a4551b 292 lcd.printString(" Roller Maze ", 0, 2);
el15mh 2:917211a4551b 293 // printf("loop \n");
el15mh 2:917211a4551b 294 lcd.drawLine(56, 40, 68, 40, FILL_BLACK);
el15mh 2:917211a4551b 295 lcd.drawLine(56, 41, 68, 41, FILL_BLACK);
el15mh 2:917211a4551b 296 lcd.drawCircle(i, j, 4, FILL_BLACK);
el15mh 2:917211a4551b 297
el15mh 2:917211a4551b 298 wait_ms(125);
el15mh 2:917211a4551b 299
el15mh 2:917211a4551b 300 for (int c = 55; c < 68; c++){
el15mh 2:917211a4551b 301 for (int d = 42; d < 47; d++){
el15mh 2:917211a4551b 302
el15mh 2:917211a4551b 303 lcd.clearPixel(c, 42);
el15mh 2:917211a4551b 304 lcd.clearPixel(c, 43);
el15mh 2:917211a4551b 305 lcd.clearPixel(c, 44);
el15mh 2:917211a4551b 306 lcd.clearPixel(c, 45);
el15mh 2:917211a4551b 307 lcd.clearPixel(c, 46);
el15mh 2:917211a4551b 308 lcd.clearPixel(c, 47);
el15mh 2:917211a4551b 309 }
el15mh 2:917211a4551b 310 }
el15mh 2:917211a4551b 311
el15mh 2:917211a4551b 312 }
el15mh 2:917211a4551b 313
el15mh 2:917211a4551b 314 lcd.refresh();
el15mh 2:917211a4551b 315 }
el15mh 2:917211a4551b 316
el15mh 2:917211a4551b 317 // printf("%i \n", i);
el15mh 2:917211a4551b 318 }
el15mh 2:917211a4551b 319 }
el15mh 2:917211a4551b 320
el15mh 2:917211a4551b 321
el15mh 2:917211a4551b 322 }
el15mh 2:917211a4551b 323
el15mh 2:917211a4551b 324 /// GAME LOOP ///
el15mh 2:917211a4551b 325 void playGame(N5110 &lcd, Gamepad &pad, FXOS8700CQ &device)
el15mh 2:917211a4551b 326 {
el15mh 2:917211a4551b 327 int exit = 0;
el15mh 2:917211a4551b 328
el15mh 2:917211a4551b 329 while (exit == 0){
el15mh 2:917211a4551b 330
el15mh 2:917211a4551b 331 _engine.readInput(pad, device);
el15mh 2:917211a4551b 332 _engine.update(pad);
el15mh 2:917211a4551b 333 // rendering screen
el15mh 2:917211a4551b 334 lcd.clear();
el15mh 2:917211a4551b 335 _engine.draw(lcd);
el15mh 2:917211a4551b 336 lcd.refresh();
el15mh 2:917211a4551b 337
el15mh 2:917211a4551b 338 wait_ms(100);
el15mh 2:917211a4551b 339
el15mh 2:917211a4551b 340 // get direction of the joystick
el15mh 2:917211a4551b 341 char d = pad.get_direction();
el15mh 2:917211a4551b 342 if ((pad.check_event(Gamepad::BACK_PRESSED)) ||
el15mh 2:917211a4551b 343 (d == W)){
el15mh 2:917211a4551b 344
el15mh 2:917211a4551b 345 exit = 1;
el15mh 2:917211a4551b 346 }
el15mh 2:917211a4551b 347 }
el15mh 2:917211a4551b 348 }
el15mh 2:917211a4551b 349
el15mh 2:917211a4551b 350 /// MENU FUNCTIONS ///
el15mh 2:917211a4551b 351
el15mh 1:21b7a5edb9c2 352 void Menu::options(N5110 &lcd, Gamepad &pad)
el15mh 0:b32f6570a26d 353 {
el15mh 1:21b7a5edb9c2 354 int exit = 0;
el15mh 0:b32f6570a26d 355 int selected = 0;
el15mh 0:b32f6570a26d 356
el15mh 0:b32f6570a26d 357 while(exit == 0) {
el15mh 0:b32f6570a26d 358
el15mh 1:21b7a5edb9c2 359 // get direction of the joystick
el15mh 1:21b7a5edb9c2 360 char d = pad.get_direction();
el15mh 1:21b7a5edb9c2 361
el15mh 1:21b7a5edb9c2 362 if ((d == NW) ||
el15mh 1:21b7a5edb9c2 363 (d == N) ||
el15mh 1:21b7a5edb9c2 364 (d == NE)){
el15mh 1:21b7a5edb9c2 365
el15mh 1:21b7a5edb9c2 366 selected -= 1;
el15mh 1:21b7a5edb9c2 367 }
el15mh 1:21b7a5edb9c2 368
el15mh 1:21b7a5edb9c2 369 if ((d == SW) ||
el15mh 1:21b7a5edb9c2 370 (d == S) ||
el15mh 1:21b7a5edb9c2 371 (d == SE)){
el15mh 1:21b7a5edb9c2 372
el15mh 1:21b7a5edb9c2 373 selected += 1;
el15mh 1:21b7a5edb9c2 374 }
el15mh 1:21b7a5edb9c2 375
el15mh 0:b32f6570a26d 376 // printf("While loop 1 \n");
el15mh 0:b32f6570a26d 377 // printf("Selected = %i \n", selected);
el15mh 0:b32f6570a26d 378 switch (selected) {
el15mh 0:b32f6570a26d 379
el15mh 0:b32f6570a26d 380 case 1:
el15mh 0:b32f6570a26d 381
el15mh 0:b32f6570a26d 382 lcd.clear();
el15mh 0:b32f6570a26d 383 // displays options page with indicator on first
el15mh 0:b32f6570a26d 384 lcd.printString("Game Options:", 0, 0);
el15mh 0:b32f6570a26d 385 lcd.printString(">Difficulty", 0, 2);
el15mh 0:b32f6570a26d 386 lcd.printString(" Ball Colour", 0, 3);
el15mh 0:b32f6570a26d 387 lcd.refresh();
el15mh 0:b32f6570a26d 388
el15mh 1:21b7a5edb9c2 389 if ((pad.check_event(Gamepad::A_PRESSED) ||
el15mh 1:21b7a5edb9c2 390 pad.check_event(Gamepad::JOY_PRESSED)) ||
el15mh 1:21b7a5edb9c2 391 (d == E)) {
el15mh 0:b32f6570a26d 392
el15mh 1:21b7a5edb9c2 393 difficultyOptions(lcd, pad);
el15mh 0:b32f6570a26d 394 }
el15mh 0:b32f6570a26d 395
el15mh 0:b32f6570a26d 396 wait_ms(250);
el15mh 0:b32f6570a26d 397
el15mh 0:b32f6570a26d 398 break;
el15mh 0:b32f6570a26d 399
el15mh 0:b32f6570a26d 400 case 2:
el15mh 0:b32f6570a26d 401
el15mh 0:b32f6570a26d 402 lcd.clear();
el15mh 0:b32f6570a26d 403 // displays options page with indicator on second
el15mh 0:b32f6570a26d 404 lcd.printString("Game Options:", 0, 0);
el15mh 0:b32f6570a26d 405 lcd.printString(" Difficulty", 0, 2);
el15mh 0:b32f6570a26d 406 lcd.printString(">Ball Colour", 0, 3);
el15mh 0:b32f6570a26d 407 lcd.refresh();
el15mh 0:b32f6570a26d 408
el15mh 0:b32f6570a26d 409 // if second option selected
el15mh 1:21b7a5edb9c2 410 if ((pad.check_event(Gamepad::A_PRESSED) ||
el15mh 1:21b7a5edb9c2 411 pad.check_event(Gamepad::JOY_PRESSED)) ||
el15mh 1:21b7a5edb9c2 412 (d == E)) {
el15mh 0:b32f6570a26d 413
el15mh 1:21b7a5edb9c2 414 lcdColourOptions(lcd, pad);
el15mh 0:b32f6570a26d 415 }
el15mh 0:b32f6570a26d 416
el15mh 0:b32f6570a26d 417 wait_ms(250);
el15mh 0:b32f6570a26d 418
el15mh 0:b32f6570a26d 419 break;
el15mh 0:b32f6570a26d 420
el15mh 0:b32f6570a26d 421 default:
el15mh 0:b32f6570a26d 422
el15mh 0:b32f6570a26d 423 selected = 1;
el15mh 0:b32f6570a26d 424
el15mh 0:b32f6570a26d 425 break;
el15mh 0:b32f6570a26d 426 }
el15mh 0:b32f6570a26d 427
el15mh 1:21b7a5edb9c2 428 if ((pad.check_event(Gamepad::BACK_PRESSED)) ||
el15mh 1:21b7a5edb9c2 429 (d == W)){
el15mh 1:21b7a5edb9c2 430
el15mh 1:21b7a5edb9c2 431 exit = 1;
el15mh 1:21b7a5edb9c2 432 }
el15mh 1:21b7a5edb9c2 433 }
el15mh 1:21b7a5edb9c2 434 }
el15mh 1:21b7a5edb9c2 435
el15mh 1:21b7a5edb9c2 436 void Menu::lcdSettings(N5110 &lcd, Gamepad &pad)
el15mh 1:21b7a5edb9c2 437 {
el15mh 1:21b7a5edb9c2 438 int exit = 0;
el15mh 1:21b7a5edb9c2 439 int selected = 0;
el15mh 1:21b7a5edb9c2 440
el15mh 1:21b7a5edb9c2 441 while(exit == 0) {
el15mh 1:21b7a5edb9c2 442
el15mh 0:b32f6570a26d 443 char d = pad.get_direction();
el15mh 0:b32f6570a26d 444
el15mh 0:b32f6570a26d 445 if ((d == NW) ||
el15mh 0:b32f6570a26d 446 (d == N) ||
el15mh 0:b32f6570a26d 447 (d == NE)){
el15mh 0:b32f6570a26d 448
el15mh 0:b32f6570a26d 449 selected -= 1;
el15mh 0:b32f6570a26d 450 }
el15mh 0:b32f6570a26d 451
el15mh 0:b32f6570a26d 452 if ((d == SW) ||
el15mh 0:b32f6570a26d 453 (d == S) ||
el15mh 0:b32f6570a26d 454 (d == SE)){
el15mh 0:b32f6570a26d 455
el15mh 0:b32f6570a26d 456 selected += 1;
el15mh 0:b32f6570a26d 457 }
el15mh 0:b32f6570a26d 458
el15mh 0:b32f6570a26d 459 // printf("While loop 1 \n");
el15mh 0:b32f6570a26d 460 // printf("Selected = %i \n", selected);
el15mh 0:b32f6570a26d 461 switch (selected) {
el15mh 0:b32f6570a26d 462
el15mh 0:b32f6570a26d 463 case 1:
el15mh 0:b32f6570a26d 464
el15mh 0:b32f6570a26d 465 lcd.clear();
el15mh 0:b32f6570a26d 466 // displays options page with indicator on first
el15mh 0:b32f6570a26d 467 lcd.printString("LCD Settings:", 0, 0);
el15mh 0:b32f6570a26d 468 lcd.printString(">Brightness", 0, 2);
el15mh 0:b32f6570a26d 469 lcd.printString(" Invert Colour", 0, 3);
el15mh 0:b32f6570a26d 470 lcd.refresh();
el15mh 0:b32f6570a26d 471
el15mh 1:21b7a5edb9c2 472 if ((pad.check_event(Gamepad::A_PRESSED) ||
el15mh 1:21b7a5edb9c2 473 pad.check_event(Gamepad::JOY_PRESSED)) ||
el15mh 1:21b7a5edb9c2 474 (d == E)) {
el15mh 2:917211a4551b 475
el15mh 0:b32f6570a26d 476
el15mh 1:21b7a5edb9c2 477 lcdBackgroundColour(lcd, pad);
el15mh 0:b32f6570a26d 478 }
el15mh 0:b32f6570a26d 479
el15mh 0:b32f6570a26d 480 wait_ms(250);
el15mh 0:b32f6570a26d 481
el15mh 0:b32f6570a26d 482 break;
el15mh 0:b32f6570a26d 483
el15mh 0:b32f6570a26d 484 case 2:
el15mh 0:b32f6570a26d 485
el15mh 0:b32f6570a26d 486 lcd.clear();
el15mh 0:b32f6570a26d 487 // displays options page with indicator on second
el15mh 0:b32f6570a26d 488 lcd.printString("LCD Settings:", 0, 0);
el15mh 0:b32f6570a26d 489 lcd.printString(" Brightness", 0, 2);
el15mh 0:b32f6570a26d 490 lcd.printString(">Invert Colour", 0, 3);
el15mh 0:b32f6570a26d 491 lcd.refresh();
el15mh 0:b32f6570a26d 492
el15mh 0:b32f6570a26d 493
el15mh 0:b32f6570a26d 494 // if second option selected
el15mh 1:21b7a5edb9c2 495 if ((pad.check_event(Gamepad::A_PRESSED) ||
el15mh 1:21b7a5edb9c2 496 pad.check_event(Gamepad::JOY_PRESSED)) ||
el15mh 1:21b7a5edb9c2 497 (d == E)) {
el15mh 2:917211a4551b 498
el15mh 0:b32f6570a26d 499
el15mh 1:21b7a5edb9c2 500 lcdInverseColour(lcd, pad);
el15mh 0:b32f6570a26d 501 }
el15mh 0:b32f6570a26d 502
el15mh 0:b32f6570a26d 503 wait_ms(250);
el15mh 0:b32f6570a26d 504
el15mh 0:b32f6570a26d 505 break;
el15mh 0:b32f6570a26d 506
el15mh 0:b32f6570a26d 507 default:
el15mh 0:b32f6570a26d 508
el15mh 0:b32f6570a26d 509 selected = 1;
el15mh 0:b32f6570a26d 510
el15mh 0:b32f6570a26d 511 break;
el15mh 0:b32f6570a26d 512 }
el15mh 0:b32f6570a26d 513
el15mh 1:21b7a5edb9c2 514 if ((pad.check_event(Gamepad::BACK_PRESSED)) ||
el15mh 1:21b7a5edb9c2 515 (d == W)){
el15mh 1:21b7a5edb9c2 516
el15mh 1:21b7a5edb9c2 517 exit = 1;
el15mh 1:21b7a5edb9c2 518 }
el15mh 1:21b7a5edb9c2 519
el15mh 1:21b7a5edb9c2 520 }
el15mh 1:21b7a5edb9c2 521
el15mh 1:21b7a5edb9c2 522
el15mh 1:21b7a5edb9c2 523 }
el15mh 1:21b7a5edb9c2 524
el15mh 1:21b7a5edb9c2 525 void Menu::soundSettings(N5110 &lcd, Gamepad &pad)
el15mh 1:21b7a5edb9c2 526 {
el15mh 1:21b7a5edb9c2 527
el15mh 1:21b7a5edb9c2 528 int exit = 0;
el15mh 1:21b7a5edb9c2 529 // pad.tone(750.0,0.1);
el15mh 1:21b7a5edb9c2 530
el15mh 1:21b7a5edb9c2 531 while (exit == 0){
el15mh 1:21b7a5edb9c2 532
el15mh 1:21b7a5edb9c2 533 lcd.clear();
el15mh 1:21b7a5edb9c2 534 lcd.printString("Sound settings", 0, 2);
el15mh 1:21b7a5edb9c2 535 lcd.refresh();
el15mh 1:21b7a5edb9c2 536
el15mh 1:21b7a5edb9c2 537 char d = pad.get_direction();
el15mh 1:21b7a5edb9c2 538
el15mh 1:21b7a5edb9c2 539 if ((pad.check_event(Gamepad::BACK_PRESSED)) ||
el15mh 1:21b7a5edb9c2 540 (d == W)){
el15mh 1:21b7a5edb9c2 541
el15mh 1:21b7a5edb9c2 542 exit = 1;
el15mh 1:21b7a5edb9c2 543 }
el15mh 1:21b7a5edb9c2 544 }
el15mh 1:21b7a5edb9c2 545
el15mh 1:21b7a5edb9c2 546 }
el15mh 1:21b7a5edb9c2 547
el15mh 2:917211a4551b 548 void Menu::controlOptions(N5110 &lcd, Gamepad &pad)
el15mh 2:917211a4551b 549 {
el15mh 2:917211a4551b 550 int selected = 0;
el15mh 2:917211a4551b 551 int exit = 0;
el15mh 2:917211a4551b 552
el15mh 2:917211a4551b 553 while (exit == 0){
el15mh 2:917211a4551b 554 char d = pad.get_direction();
el15mh 2:917211a4551b 555
el15mh 2:917211a4551b 556 if (d == W){
el15mh 2:917211a4551b 557
el15mh 2:917211a4551b 558 selected -= 1;
el15mh 2:917211a4551b 559 }
el15mh 2:917211a4551b 560
el15mh 2:917211a4551b 561 if (d == E){
el15mh 2:917211a4551b 562
el15mh 2:917211a4551b 563 selected += 1;
el15mh 2:917211a4551b 564 }
el15mh 2:917211a4551b 565
el15mh 2:917211a4551b 566 switch(selected){
el15mh 2:917211a4551b 567
el15mh 2:917211a4551b 568 case 1:
el15mh 2:917211a4551b 569
el15mh 2:917211a4551b 570 while (selected == 0){
el15mh 2:917211a4551b 571
el15mh 2:917211a4551b 572 lcd.clear();
el15mh 2:917211a4551b 573 lcd.printString("Control: ", 0, 0);
el15mh 2:917211a4551b 574 lcd.printString(" Joystick", 0, 2);
el15mh 2:917211a4551b 575
el15mh 2:917211a4551b 576 lcd.refresh();
el15mh 2:917211a4551b 577 wait_ms(250); // 250ms propogation delay
el15mh 2:917211a4551b 578
el15mh 2:917211a4551b 579 if (pad.check_event(Gamepad::A_PRESSED)||
el15mh 2:917211a4551b 580 pad.check_event(Gamepad::JOY_PRESSED)){
el15mh 2:917211a4551b 581
el15mh 2:917211a4551b 582 CONTROL = true;
el15mh 2:917211a4551b 583 }
el15mh 2:917211a4551b 584
el15mh 2:917211a4551b 585 break;
el15mh 2:917211a4551b 586
el15mh 2:917211a4551b 587 }
el15mh 2:917211a4551b 588
el15mh 2:917211a4551b 589
el15mh 2:917211a4551b 590 case 2:
el15mh 2:917211a4551b 591
el15mh 2:917211a4551b 592 lcd.clear();
el15mh 2:917211a4551b 593 lcd.printString("Difficulty: ", 0, 0);
el15mh 2:917211a4551b 594 lcd.printString(" Easy", 0, 2);
el15mh 2:917211a4551b 595 lcd.printString(">Hard", 0, 3);
el15mh 2:917211a4551b 596 lcd.refresh();
el15mh 2:917211a4551b 597
el15mh 2:917211a4551b 598 wait_ms(250); // 250ms propogation delay
el15mh 2:917211a4551b 599
el15mh 2:917211a4551b 600 if ((pad.check_event(Gamepad::A_PRESSED) ||
el15mh 2:917211a4551b 601 pad.check_event(Gamepad::JOY_PRESSED)) ||
el15mh 2:917211a4551b 602 (d == E)) {
el15mh 2:917211a4551b 603
el15mh 2:917211a4551b 604
el15mh 2:917211a4551b 605 // maze.mazeIndex = 1;
el15mh 2:917211a4551b 606 lcd.clear();
el15mh 2:917211a4551b 607 lcd.printString("Hard mode", 0, 1);
el15mh 2:917211a4551b 608 lcd.refresh();
el15mh 2:917211a4551b 609 wait(2);
el15mh 2:917211a4551b 610
el15mh 2:917211a4551b 611 exit = 1;
el15mh 2:917211a4551b 612 }
el15mh 2:917211a4551b 613
el15mh 2:917211a4551b 614 break;
el15mh 2:917211a4551b 615
el15mh 2:917211a4551b 616 default:
el15mh 2:917211a4551b 617
el15mh 2:917211a4551b 618 selected = 1;
el15mh 2:917211a4551b 619
el15mh 2:917211a4551b 620 break;
el15mh 2:917211a4551b 621
el15mh 2:917211a4551b 622 }
el15mh 2:917211a4551b 623
el15mh 2:917211a4551b 624 if (pad.check_event(Gamepad::BACK_PRESSED)){
el15mh 2:917211a4551b 625
el15mh 2:917211a4551b 626 exit = 1;
el15mh 2:917211a4551b 627 }
el15mh 2:917211a4551b 628
el15mh 2:917211a4551b 629 }
el15mh 2:917211a4551b 630 }
el15mh 2:917211a4551b 631
el15mh 2:917211a4551b 632
el15mh 1:21b7a5edb9c2 633 void Menu::difficultyOptions(N5110 &lcd, Gamepad &pad)
el15mh 1:21b7a5edb9c2 634 {
el15mh 1:21b7a5edb9c2 635 int selected = 0;
el15mh 1:21b7a5edb9c2 636 int exit = 0;
el15mh 1:21b7a5edb9c2 637
el15mh 1:21b7a5edb9c2 638 while(exit == 0){
el15mh 1:21b7a5edb9c2 639
el15mh 0:b32f6570a26d 640 char d = pad.get_direction();
el15mh 0:b32f6570a26d 641
el15mh 0:b32f6570a26d 642 if ((d == NW) ||
el15mh 0:b32f6570a26d 643 (d == N) ||
el15mh 0:b32f6570a26d 644 (d == NE)){
el15mh 0:b32f6570a26d 645
el15mh 0:b32f6570a26d 646 selected -= 1;
el15mh 0:b32f6570a26d 647 }
el15mh 0:b32f6570a26d 648
el15mh 0:b32f6570a26d 649 if ((d == SW) ||
el15mh 0:b32f6570a26d 650 (d == S) ||
el15mh 0:b32f6570a26d 651 (d == SE)){
el15mh 0:b32f6570a26d 652
el15mh 0:b32f6570a26d 653 selected += 1;
el15mh 0:b32f6570a26d 654 }
el15mh 0:b32f6570a26d 655
el15mh 0:b32f6570a26d 656 switch(selected){
el15mh 0:b32f6570a26d 657
el15mh 0:b32f6570a26d 658 case 1:
el15mh 0:b32f6570a26d 659
el15mh 0:b32f6570a26d 660 lcd.clear();
el15mh 0:b32f6570a26d 661 lcd.printString("Difficulty: ", 0, 0);
el15mh 0:b32f6570a26d 662 lcd.printString(">Easy", 0, 2);
el15mh 0:b32f6570a26d 663 lcd.printString(" Hard", 0, 3);
el15mh 0:b32f6570a26d 664 lcd.refresh();
el15mh 0:b32f6570a26d 665
el15mh 1:21b7a5edb9c2 666 wait_ms(250); // 250ms propogation delay
el15mh 1:21b7a5edb9c2 667
el15mh 1:21b7a5edb9c2 668 if ((pad.check_event(Gamepad::A_PRESSED) ||
el15mh 1:21b7a5edb9c2 669 pad.check_event(Gamepad::JOY_PRESSED)) ||
el15mh 1:21b7a5edb9c2 670 (d == E)) {
el15mh 0:b32f6570a26d 671
el15mh 2:917211a4551b 672 _mazeIndex = 0;
el15mh 2:917211a4551b 673
el15mh 0:b32f6570a26d 674 lcd.clear();
el15mh 0:b32f6570a26d 675 lcd.printString("Easy mode", 0, 1);
el15mh 0:b32f6570a26d 676 lcd.refresh();
el15mh 0:b32f6570a26d 677 wait(2);
el15mh 0:b32f6570a26d 678
el15mh 0:b32f6570a26d 679 exit = 1;
el15mh 0:b32f6570a26d 680 }
el15mh 0:b32f6570a26d 681
el15mh 0:b32f6570a26d 682 break;
el15mh 0:b32f6570a26d 683
el15mh 0:b32f6570a26d 684 case 2:
el15mh 0:b32f6570a26d 685
el15mh 0:b32f6570a26d 686 lcd.clear();
el15mh 0:b32f6570a26d 687 lcd.printString("Difficulty: ", 0, 0);
el15mh 0:b32f6570a26d 688 lcd.printString(" Easy", 0, 2);
el15mh 0:b32f6570a26d 689 lcd.printString(">Hard", 0, 3);
el15mh 0:b32f6570a26d 690 lcd.refresh();
el15mh 0:b32f6570a26d 691
el15mh 1:21b7a5edb9c2 692 wait_ms(250); // 250ms propogation delay
el15mh 1:21b7a5edb9c2 693
el15mh 1:21b7a5edb9c2 694 if ((pad.check_event(Gamepad::A_PRESSED) ||
el15mh 1:21b7a5edb9c2 695 pad.check_event(Gamepad::JOY_PRESSED)) ||
el15mh 1:21b7a5edb9c2 696 (d == E)) {
el15mh 2:917211a4551b 697
el15mh 2:917211a4551b 698 _mazeIndex = 1;
el15mh 0:b32f6570a26d 699
el15mh 0:b32f6570a26d 700 // maze.mazeIndex = 1;
el15mh 0:b32f6570a26d 701 lcd.clear();
el15mh 0:b32f6570a26d 702 lcd.printString("Hard mode", 0, 1);
el15mh 0:b32f6570a26d 703 lcd.refresh();
el15mh 0:b32f6570a26d 704 wait(2);
el15mh 0:b32f6570a26d 705
el15mh 0:b32f6570a26d 706 exit = 1;
el15mh 0:b32f6570a26d 707 }
el15mh 0:b32f6570a26d 708
el15mh 0:b32f6570a26d 709 break;
el15mh 0:b32f6570a26d 710
el15mh 0:b32f6570a26d 711 default:
el15mh 0:b32f6570a26d 712
el15mh 0:b32f6570a26d 713 selected = 1;
el15mh 0:b32f6570a26d 714
el15mh 0:b32f6570a26d 715 break;
el15mh 0:b32f6570a26d 716
el15mh 0:b32f6570a26d 717 }
el15mh 1:21b7a5edb9c2 718
el15mh 1:21b7a5edb9c2 719 if ((pad.check_event(Gamepad::BACK_PRESSED)) ||
el15mh 1:21b7a5edb9c2 720 (d == W)){
el15mh 1:21b7a5edb9c2 721
el15mh 1:21b7a5edb9c2 722 exit = 1;
el15mh 1:21b7a5edb9c2 723 }
el15mh 1:21b7a5edb9c2 724
el15mh 1:21b7a5edb9c2 725 }
el15mh 1:21b7a5edb9c2 726
el15mh 1:21b7a5edb9c2 727
el15mh 1:21b7a5edb9c2 728 }
el15mh 1:21b7a5edb9c2 729
el15mh 1:21b7a5edb9c2 730 void Menu::lcdColourOptions(N5110 &lcd, Gamepad &pad)
el15mh 1:21b7a5edb9c2 731 {
el15mh 1:21b7a5edb9c2 732 int selected = 0;
el15mh 1:21b7a5edb9c2 733 int exit = 0;
el15mh 1:21b7a5edb9c2 734
el15mh 1:21b7a5edb9c2 735 while(exit == 0){
el15mh 1:21b7a5edb9c2 736
el15mh 0:b32f6570a26d 737 char d = pad.get_direction();
el15mh 0:b32f6570a26d 738
el15mh 0:b32f6570a26d 739 if ((d == NW) ||
el15mh 0:b32f6570a26d 740 (d == N) ||
el15mh 0:b32f6570a26d 741 (d == NE)){
el15mh 0:b32f6570a26d 742
el15mh 0:b32f6570a26d 743 selected -= 1;
el15mh 0:b32f6570a26d 744 }
el15mh 0:b32f6570a26d 745
el15mh 0:b32f6570a26d 746 if ((d == SW) ||
el15mh 0:b32f6570a26d 747 (d == S) ||
el15mh 0:b32f6570a26d 748 (d == SE)){
el15mh 0:b32f6570a26d 749
el15mh 0:b32f6570a26d 750 selected += 1;
el15mh 0:b32f6570a26d 751 }
el15mh 0:b32f6570a26d 752
el15mh 0:b32f6570a26d 753 switch(selected){
el15mh 0:b32f6570a26d 754
el15mh 0:b32f6570a26d 755 case 1:
el15mh 0:b32f6570a26d 756
el15mh 0:b32f6570a26d 757 // printf("case 2.1");
el15mh 0:b32f6570a26d 758
el15mh 0:b32f6570a26d 759 lcd.clear();
el15mh 0:b32f6570a26d 760 lcd.printString("Ball colour: ", 0, 0);
el15mh 2:917211a4551b 761 lcd.printString(">Outline", 0, 2);
el15mh 0:b32f6570a26d 762 lcd.printString(" Solid", 0, 3);
el15mh 0:b32f6570a26d 763 lcd.refresh();
el15mh 0:b32f6570a26d 764
el15mh 1:21b7a5edb9c2 765 wait_ms(250); // 250ms propogation delay
el15mh 1:21b7a5edb9c2 766
el15mh 1:21b7a5edb9c2 767 if ((pad.check_event(Gamepad::A_PRESSED) ||
el15mh 2:917211a4551b 768 pad.check_event(Gamepad::JOY_PRESSED)) ||
el15mh 2:917211a4551b 769 (d == E)) {
el15mh 0:b32f6570a26d 770
el15mh 0:b32f6570a26d 771 // ball.ballColour = 0;
el15mh 0:b32f6570a26d 772 lcd.clear();
el15mh 2:917211a4551b 773 lcd.printString("Outline", 0, 1);
el15mh 0:b32f6570a26d 774 lcd.refresh();
el15mh 0:b32f6570a26d 775 wait(2);
el15mh 0:b32f6570a26d 776
el15mh 0:b32f6570a26d 777 exit = 1;
el15mh 0:b32f6570a26d 778 }
el15mh 0:b32f6570a26d 779
el15mh 0:b32f6570a26d 780 break;
el15mh 0:b32f6570a26d 781
el15mh 0:b32f6570a26d 782 case 2:
el15mh 0:b32f6570a26d 783
el15mh 0:b32f6570a26d 784 // printf("case 2.2");
el15mh 0:b32f6570a26d 785
el15mh 0:b32f6570a26d 786 lcd.clear();
el15mh 0:b32f6570a26d 787 lcd.printString("Ball colour: ", 0, 0);
el15mh 2:917211a4551b 788 lcd.printString(" Outline", 0, 2);
el15mh 0:b32f6570a26d 789 lcd.printString(">Solid", 0, 3);
el15mh 0:b32f6570a26d 790 lcd.refresh();
el15mh 0:b32f6570a26d 791
el15mh 1:21b7a5edb9c2 792 wait_ms(250); // 250ms propogation delay
el15mh 2:917211a4551b 793
el15mh 1:21b7a5edb9c2 794
el15mh 1:21b7a5edb9c2 795 if ((pad.check_event(Gamepad::A_PRESSED) ||
el15mh 1:21b7a5edb9c2 796 pad.check_event(Gamepad::JOY_PRESSED)) ||
el15mh 1:21b7a5edb9c2 797 (d == E)) {
el15mh 0:b32f6570a26d 798
el15mh 0:b32f6570a26d 799 // ball.ballColour = 1;
el15mh 0:b32f6570a26d 800 lcd.clear();
el15mh 0:b32f6570a26d 801 lcd.printString("Solid", 0, 1);
el15mh 0:b32f6570a26d 802 lcd.refresh();
el15mh 0:b32f6570a26d 803 wait(2);
el15mh 0:b32f6570a26d 804
el15mh 0:b32f6570a26d 805 exit = 1;
el15mh 0:b32f6570a26d 806 }
el15mh 0:b32f6570a26d 807
el15mh 0:b32f6570a26d 808 break;
el15mh 0:b32f6570a26d 809
el15mh 0:b32f6570a26d 810 default:
el15mh 0:b32f6570a26d 811
el15mh 0:b32f6570a26d 812 selected = 1;
el15mh 0:b32f6570a26d 813
el15mh 0:b32f6570a26d 814 break;
el15mh 0:b32f6570a26d 815 }
el15mh 0:b32f6570a26d 816
el15mh 1:21b7a5edb9c2 817 if ((pad.check_event(Gamepad::BACK_PRESSED)) ||
el15mh 1:21b7a5edb9c2 818 (d == W)){
el15mh 0:b32f6570a26d 819
el15mh 0:b32f6570a26d 820 exit = 1;
el15mh 0:b32f6570a26d 821 }
el15mh 0:b32f6570a26d 822 }
el15mh 1:21b7a5edb9c2 823
el15mh 0:b32f6570a26d 824
el15mh 0:b32f6570a26d 825 }
el15mh 0:b32f6570a26d 826
el15mh 1:21b7a5edb9c2 827 void Menu::lcdInverseColour(N5110 &lcd, Gamepad &pad)
el15mh 0:b32f6570a26d 828 {
el15mh 0:b32f6570a26d 829 int exit = 0;
el15mh 0:b32f6570a26d 830
el15mh 0:b32f6570a26d 831 while (exit == 0) {
el15mh 0:b32f6570a26d 832
el15mh 0:b32f6570a26d 833 lcd.clear();
el15mh 0:b32f6570a26d 834 lcd.printString("Press A to", 0, 0);
el15mh 0:b32f6570a26d 835 lcd.printString("invert colours", 0, 1);
el15mh 0:b32f6570a26d 836 lcd.printString("Press B to", 0, 3);
el15mh 0:b32f6570a26d 837 lcd.printString("revert to", 0, 4);
el15mh 0:b32f6570a26d 838 lcd.printString("normal", 0, 5);
el15mh 0:b32f6570a26d 839
el15mh 0:b32f6570a26d 840 if (pad.check_event(Gamepad::A_PRESSED)){
el15mh 0:b32f6570a26d 841
el15mh 0:b32f6570a26d 842 lcd.inverseMode();
el15mh 0:b32f6570a26d 843
el15mh 0:b32f6570a26d 844 }
el15mh 0:b32f6570a26d 845
el15mh 0:b32f6570a26d 846 if (pad.check_event(Gamepad::B_PRESSED)){
el15mh 0:b32f6570a26d 847
el15mh 0:b32f6570a26d 848 lcd.normalMode();
el15mh 0:b32f6570a26d 849
el15mh 0:b32f6570a26d 850 }
el15mh 0:b32f6570a26d 851
el15mh 0:b32f6570a26d 852 lcd.refresh();
el15mh 0:b32f6570a26d 853
el15mh 1:21b7a5edb9c2 854 char d = pad.get_direction();
el15mh 1:21b7a5edb9c2 855
el15mh 1:21b7a5edb9c2 856 if ((pad.check_event(Gamepad::BACK_PRESSED)) ||
el15mh 1:21b7a5edb9c2 857 (d == W)){
el15mh 0:b32f6570a26d 858
el15mh 0:b32f6570a26d 859 exit = 1;
el15mh 0:b32f6570a26d 860 }
el15mh 0:b32f6570a26d 861 }
el15mh 1:21b7a5edb9c2 862
el15mh 0:b32f6570a26d 863
el15mh 0:b32f6570a26d 864 }
el15mh 0:b32f6570a26d 865
el15mh 1:21b7a5edb9c2 866 void Menu::lcdBackgroundColour(N5110 &lcd, Gamepad &pad)
el15mh 0:b32f6570a26d 867 {
el15mh 1:21b7a5edb9c2 868 // method to change the brightness of the LED backlight
el15mh 0:b32f6570a26d 869 int exit = 0;
el15mh 0:b32f6570a26d 870
el15mh 0:b32f6570a26d 871 while (exit == 0) {
el15mh 0:b32f6570a26d 872
el15mh 0:b32f6570a26d 873 lcd.clear();
el15mh 0:b32f6570a26d 874 lcd.printString("BRIGHTNESS", 0, 0);
el15mh 0:b32f6570a26d 875 lcd.printString("Use DIAL --->", 0, 1);
el15mh 0:b32f6570a26d 876 lcd.printString("to adjust", 0, 2);
el15mh 0:b32f6570a26d 877
el15mh 0:b32f6570a26d 878 double brightness = pad.read_pot(); // returns value between 0.0 - 1.0
el15mh 0:b32f6570a26d 879
el15mh 0:b32f6570a26d 880 lcd.setBrightness(brightness);
el15mh 0:b32f6570a26d 881 lcd.refresh();
el15mh 0:b32f6570a26d 882
el15mh 0:b32f6570a26d 883 int width = brightness * 40;
el15mh 0:b32f6570a26d 884
el15mh 0:b32f6570a26d 885 lcd.drawRect(10, 30, 41, 8, FILL_TRANSPARENT);
el15mh 0:b32f6570a26d 886 lcd.drawRect(11, 31, width, 6, FILL_BLACK);
el15mh 0:b32f6570a26d 887 lcd.refresh();
el15mh 0:b32f6570a26d 888
el15mh 0:b32f6570a26d 889 wait_ms(10);
el15mh 0:b32f6570a26d 890
el15mh 1:21b7a5edb9c2 891 char d = pad.get_direction();
el15mh 1:21b7a5edb9c2 892
el15mh 1:21b7a5edb9c2 893 if ((pad.check_event(Gamepad::BACK_PRESSED)) ||
el15mh 1:21b7a5edb9c2 894 (d == W)){
el15mh 0:b32f6570a26d 895
el15mh 0:b32f6570a26d 896 exit = 1;
el15mh 0:b32f6570a26d 897 }
el15mh 0:b32f6570a26d 898
el15mh 0:b32f6570a26d 899 }
el15mh 0:b32f6570a26d 900 }
el15mh 0:b32f6570a26d 901
el15mh 2:917211a4551b 902 void Menu::animateJoystick(N5110 &lcd)
el15mh 2:917211a4551b 903 {
el15mh 2:917211a4551b 904 drawVerticalJoystick(lcd);
el15mh 2:917211a4551b 905
el15mh 2:917211a4551b 906 }
el15mh 1:21b7a5edb9c2 907
el15mh 2:917211a4551b 908
el15mh 2:917211a4551b 909 void Menu::drawVerticalJoystick(N5110 &lcd)
el15mh 2:917211a4551b 910 {
el15mh 2:917211a4551b 911 /* Drawing a vertical joystick image
el15mh 2:917211a4551b 912
el15mh 2:917211a4551b 913 33 ####
el15mh 2:917211a4551b 914 34 ############
el15mh 2:917211a4551b 915 35 ################
el15mh 2:917211a4551b 916 36 ##
el15mh 2:917211a4551b 917 37 ##
el15mh 2:917211a4551b 918 38 ########
el15mh 2:917211a4551b 919 39 ################
el15mh 2:917211a4551b 920 40 ######################
el15mh 2:917211a4551b 921 41 ########################
el15mh 2:917211a4551b 922 42 ##########################
el15mh 2:917211a4551b 923 43 ##########################
el15mh 2:917211a4551b 924 44 23456789012345678901234567
el15mh 2:917211a4551b 925 3 4 5
el15mh 2:917211a4551b 926
el15mh 2:917211a4551b 927 */
el15mh 2:917211a4551b 928
el15mh 2:917211a4551b 929 for (int i = 32; i < 58; i++){
el15mh 2:917211a4551b 930 lcd.setPixel(i, 43);
el15mh 2:917211a4551b 931 lcd.setPixel(i, 42);
el15mh 2:917211a4551b 932 }
el15mh 2:917211a4551b 933 for (int i = 33; i < 57; i++){
el15mh 2:917211a4551b 934 lcd.setPixel(i, 41);
el15mh 2:917211a4551b 935 }
el15mh 2:917211a4551b 936 for (int i = 34; i < 56; i++){
el15mh 2:917211a4551b 937 lcd.setPixel(i, 40);
el15mh 2:917211a4551b 938 }
el15mh 2:917211a4551b 939 for (int i = 37; i < 54; i++){
el15mh 2:917211a4551b 940 lcd.setPixel(i, 39);
el15mh 2:917211a4551b 941 }
el15mh 2:917211a4551b 942 for (int i = 41; i < 49; i++){
el15mh 2:917211a4551b 943 lcd.setPixel(i, 38);
el15mh 2:917211a4551b 944 }
el15mh 2:917211a4551b 945
el15mh 2:917211a4551b 946 lcd.setPixel(44, 37);
el15mh 2:917211a4551b 947 lcd.setPixel(45, 37);
el15mh 2:917211a4551b 948 lcd.setPixel(44, 36);
el15mh 2:917211a4551b 949 lcd.setPixel(45, 36);
el15mh 2:917211a4551b 950
el15mh 2:917211a4551b 951 for (int i = 37; i < 54; i++){
el15mh 2:917211a4551b 952 lcd.setPixel(i, 35);
el15mh 2:917211a4551b 953 }
el15mh 2:917211a4551b 954 for (int i = 39; i < 52; i++){
el15mh 2:917211a4551b 955 lcd.setPixel(i, 34);
el15mh 2:917211a4551b 956 }
el15mh 2:917211a4551b 957 for (int i = 43; i < 47; i++){
el15mh 2:917211a4551b 958 lcd.setPixel(i, 33);
el15mh 2:917211a4551b 959 }
el15mh 2:917211a4551b 960 }
el15mh 2:917211a4551b 961
el15mh 2:917211a4551b 962
el15mh 2:917211a4551b 963
el15mh 2:917211a4551b 964