FINAL VERSION

Dependencies:   mbed

Committer:
jamesheavey
Date:
Sat May 04 18:43:08 2019 +0000
Revision:
58:a159cd976aca
Parent:
57:d498dd835cfc
Child:
59:fdc05d5778a6
maybe move flash_screen to the engine

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jamesheavey 0:7d4d2023ed9c 1 ///////// pre-processor directives ////////
jamesheavey 0:7d4d2023ed9c 2 #include "mbed.h"
jamesheavey 0:7d4d2023ed9c 3 #include "Gamepad.h"
jamesheavey 0:7d4d2023ed9c 4 #include "N5110.h"
jamesheavey 27:1b5038b0a7a2 5 #include "BreakoutEngine.h"
jamesheavey 3:5719d0fe94ed 6 #include "Bitmap.h"
jamesheavey 57:d498dd835cfc 7 #include <iostream>
jamesheavey 8:1ab6d90c4d60 8 #include "Sprites.h"
jamesheavey 14:38560375d420 9 //#include "MotionControl.h"
jamesheavey 0:7d4d2023ed9c 10
jamesheavey 0:7d4d2023ed9c 11 #ifdef WITH_TESTING
jamesheavey 0:7d4d2023ed9c 12 # include "tests.h"
jamesheavey 0:7d4d2023ed9c 13 #endif
jamesheavey 0:7d4d2023ed9c 14
jamesheavey 9:f6f0f39538c7 15 #define PADDLE_WIDTH 15
jamesheavey 0:7d4d2023ed9c 16 #define PADDLE_HEIGHT 2
jamesheavey 0:7d4d2023ed9c 17 #define BALL_SIZE 2
jamesheavey 0:7d4d2023ed9c 18 #define BALL_SPEED 3
jamesheavey 0:7d4d2023ed9c 19
jamesheavey 0:7d4d2023ed9c 20 /////////////// structs /////////////////
jamesheavey 0:7d4d2023ed9c 21 struct UserInput {
jamesheavey 0:7d4d2023ed9c 22 Direction d;
jamesheavey 0:7d4d2023ed9c 23 float mag;
jamesheavey 0:7d4d2023ed9c 24 };
jamesheavey 0:7d4d2023ed9c 25 /////////////// objects ///////////////
jamesheavey 0:7d4d2023ed9c 26 N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);
jamesheavey 0:7d4d2023ed9c 27 Gamepad pad;
jamesheavey 27:1b5038b0a7a2 28 BreakoutEngine breakout;
jamesheavey 0:7d4d2023ed9c 29
jamesheavey 0:7d4d2023ed9c 30 ///////////// prototypes ///////////////
jamesheavey 0:7d4d2023ed9c 31 void init();
jamesheavey 0:7d4d2023ed9c 32 void update_game(UserInput input);
jamesheavey 0:7d4d2023ed9c 33 void render();
jamesheavey 53:8e3da0b58fe9 34 void main_menu();
jamesheavey 51:9d5c10a88b22 35 void settings();
jamesheavey 50:3da51f34e253 36 void how_to_play();
jamesheavey 10:9f445faa892c 37 void end_screen();
jamesheavey 58:a159cd976aca 38 void victory_screen();
jamesheavey 49:31eb7807dbd3 39 void title_screen();
jamesheavey 47:1d1a827be81b 40 void main_game(bool tilt);
jamesheavey 58:a159cd976aca 41 void flash_screen(N5110 &lcd);
jamesheavey 47:1d1a827be81b 42 int prev_score = 0;
jamesheavey 47:1d1a827be81b 43
jamesheavey 47:1d1a827be81b 44 bool tilt = false;
jamesheavey 0:7d4d2023ed9c 45
jamesheavey 0:7d4d2023ed9c 46 ///////////// functions ////////////////
jamesheavey 0:7d4d2023ed9c 47 int main()
jamesheavey 0:7d4d2023ed9c 48 {
jamesheavey 0:7d4d2023ed9c 49 #ifdef WITH_TESTING
jamesheavey 0:7d4d2023ed9c 50 int number_of_failures = run_all_tests();
jamesheavey 0:7d4d2023ed9c 51
jamesheavey 0:7d4d2023ed9c 52 if(number_of_failures > 0) return number_of_failures;
jamesheavey 0:7d4d2023ed9c 53 #endif
jamesheavey 58:a159cd976aca 54
jamesheavey 58:a159cd976aca 55 init(); // initialise the gamepad
jamesheavey 58:a159cd976aca 56 title_screen(); // run the title screen
jamesheavey 3:5719d0fe94ed 57
jamesheavey 0:7d4d2023ed9c 58 }
jamesheavey 0:7d4d2023ed9c 59
jamesheavey 0:7d4d2023ed9c 60 // initialies all classes and libraries
jamesheavey 56:f9e586348e0b 61 void init()
jamesheavey 0:7d4d2023ed9c 62 {
jamesheavey 0:7d4d2023ed9c 63 // need to initialise LCD and Gamepad
jamesheavey 0:7d4d2023ed9c 64 lcd.init();
jamesheavey 0:7d4d2023ed9c 65 pad.init();
jamesheavey 0:7d4d2023ed9c 66
jamesheavey 0:7d4d2023ed9c 67 }
jamesheavey 0:7d4d2023ed9c 68
jamesheavey 0:7d4d2023ed9c 69 // this function draws each frame on the LCD
jamesheavey 0:7d4d2023ed9c 70 void render()
jamesheavey 0:7d4d2023ed9c 71 {
jamesheavey 0:7d4d2023ed9c 72 // clear screen, re-draw and refresh
jamesheavey 0:7d4d2023ed9c 73 lcd.clear();
jamesheavey 26:25eea19c5fbe 74 breakout.draw(lcd);
jamesheavey 0:7d4d2023ed9c 75 lcd.refresh();
jamesheavey 0:7d4d2023ed9c 76 }
jamesheavey 0:7d4d2023ed9c 77
jamesheavey 58:a159cd976aca 78 void title_screen() {
jamesheavey 58:a159cd976aca 79 tilt = false; // reset the tilt variable so that on start, joystick is default
jamesheavey 58:a159cd976aca 80 prev_score = 0; // reset the prev_score variable so that on reset, prev score is returned to 0, and therefore the multiplier is too
jamesheavey 58:a159cd976aca 81
jamesheavey 58:a159cd976aca 82 Bitmap breakwhite(breakwhite_data, 48, 84); // assign the title screen sprites
jamesheavey 58:a159cd976aca 83 Bitmap breakblack(breakblack_data, 48, 84);
jamesheavey 58:a159cd976aca 84
jamesheavey 58:a159cd976aca 85 lcd.clear();
jamesheavey 58:a159cd976aca 86
jamesheavey 58:a159cd976aca 87 breakblack.render(lcd, 0, 0); // render the first frame
jamesheavey 58:a159cd976aca 88 lcd.refresh();
jamesheavey 58:a159cd976aca 89 pad.leds_off();
jamesheavey 58:a159cd976aca 90 wait(0.5);
jamesheavey 58:a159cd976aca 91
jamesheavey 58:a159cd976aca 92 while (pad.check_event(Gamepad::START_PRESSED) == false) { // while start is not pressed alternate sprites
jamesheavey 58:a159cd976aca 93
jamesheavey 58:a159cd976aca 94 lcd.clear();
jamesheavey 58:a159cd976aca 95
jamesheavey 58:a159cd976aca 96 breakwhite.render(lcd, 0, 0);
jamesheavey 58:a159cd976aca 97 lcd.refresh();
jamesheavey 58:a159cd976aca 98 pad.leds_on();
jamesheavey 58:a159cd976aca 99 wait(0.5);
jamesheavey 58:a159cd976aca 100
jamesheavey 58:a159cd976aca 101 lcd.clear();
jamesheavey 58:a159cd976aca 102
jamesheavey 58:a159cd976aca 103 breakblack.render(lcd, 0, 0);
jamesheavey 58:a159cd976aca 104 lcd.refresh();
jamesheavey 58:a159cd976aca 105 pad.leds_off();
jamesheavey 58:a159cd976aca 106 wait(0.5);
jamesheavey 58:a159cd976aca 107 }
jamesheavey 58:a159cd976aca 108
jamesheavey 58:a159cd976aca 109 pad.tone(750.0,0.3);
jamesheavey 58:a159cd976aca 110 wait(0.2);
jamesheavey 58:a159cd976aca 111 main_menu(); // load main menu
jamesheavey 58:a159cd976aca 112 }
jamesheavey 58:a159cd976aca 113
jamesheavey 58:a159cd976aca 114
jamesheavey 53:8e3da0b58fe9 115 void main_menu() {
jamesheavey 14:38560375d420 116
jamesheavey 50:3da51f34e253 117 lcd.clear();
jamesheavey 50:3da51f34e253 118 lcd.printString(" START ",0,2); // start with default as joystick
jamesheavey 50:3da51f34e253 119 lcd.printString(" SETTINGS ",0,3); // choose between joystick and tilt
jamesheavey 50:3da51f34e253 120 lcd.printString(" HOW TO PLAY ",0,4); // brief text on how to do stuff
jamesheavey 50:3da51f34e253 121 lcd.refresh();
jamesheavey 56:f9e586348e0b 122 wait(0.3);
jamesheavey 50:3da51f34e253 123
jamesheavey 53:8e3da0b58fe9 124 int pointer = 2;
jamesheavey 52:652b5f51319d 125
jamesheavey 58:a159cd976aca 126 while (pad.check_event(Gamepad::A_PRESSED) == false) {
jamesheavey 53:8e3da0b58fe9 127 lcd.clear();
jamesheavey 53:8e3da0b58fe9 128 lcd.printString(" START ",0,2); // start with default as joystick
jamesheavey 53:8e3da0b58fe9 129 lcd.printString(" SETTINGS ",0,3); // choose between joystick and tilt
jamesheavey 53:8e3da0b58fe9 130 lcd.printString(" HOW TO PLAY ",0,4); // brief text on how to do stuff
jamesheavey 56:f9e586348e0b 131 lcd.printString(" >",0,pointer);
jamesheavey 53:8e3da0b58fe9 132 lcd.refresh();
jamesheavey 53:8e3da0b58fe9 133 wait(0.1);
jamesheavey 58:a159cd976aca 134 if (pad.check_event(Gamepad::L_PRESSED) && pointer > 2) { // if L is pressed and pointer isnt already on START, move it up one line
jamesheavey 50:3da51f34e253 135 pointer -= 1;
jamesheavey 53:8e3da0b58fe9 136 pad.tone(750.0,0.3);
jamesheavey 53:8e3da0b58fe9 137 wait(0.1);
jamesheavey 58:a159cd976aca 138 } else if (pad.check_event(Gamepad::R_PRESSED) && pointer < 4) { // if R is pressed and pointer isnt already on HOW TO PLAY, move it down one line
jamesheavey 50:3da51f34e253 139 pointer += 1;
jamesheavey 53:8e3da0b58fe9 140 pad.tone(750.0,0.3);
jamesheavey 53:8e3da0b58fe9 141 wait(0.1);
jamesheavey 50:3da51f34e253 142 }
jamesheavey 3:5719d0fe94ed 143
jamesheavey 50:3da51f34e253 144 }
jamesheavey 58:a159cd976aca 145 if (pointer == 2) { // if START was selected on exit of the while loop, run main game with the appropriate tilt/joystick setting
jamesheavey 56:f9e586348e0b 146 pad.tone(750.0,0.3);
jamesheavey 52:652b5f51319d 147 main_game(tilt);
jamesheavey 51:9d5c10a88b22 148 }
jamesheavey 58:a159cd976aca 149 else if (pointer == 3){ // if SETTINGS was selected, enter the settings menu
jamesheavey 56:f9e586348e0b 150 pad.tone(750.0,0.3);
jamesheavey 51:9d5c10a88b22 151 settings();
jamesheavey 51:9d5c10a88b22 152 }
jamesheavey 58:a159cd976aca 153 else if (pointer == 4){ // if HOW TO PLAY WAS SELECTED, display instructions on how to play
jamesheavey 56:f9e586348e0b 154 pad.tone(750.0,0.3);
jamesheavey 51:9d5c10a88b22 155 how_to_play();
jamesheavey 51:9d5c10a88b22 156 }
jamesheavey 50:3da51f34e253 157 }
jamesheavey 50:3da51f34e253 158
jamesheavey 52:652b5f51319d 159 void settings() {
jamesheavey 50:3da51f34e253 160
jamesheavey 50:3da51f34e253 161 lcd.clear();
jamesheavey 58:a159cd976aca 162 lcd.printString(" JOYSTICK ",0,2); // choose joystick
jamesheavey 58:a159cd976aca 163 lcd.printString(" TILT ",0,3); // choose tilt
jamesheavey 50:3da51f34e253 164 lcd.refresh();
jamesheavey 55:b7bde601c23e 165 wait(0.3);
jamesheavey 53:8e3da0b58fe9 166
jamesheavey 53:8e3da0b58fe9 167 int pointer = 2;
jamesheavey 52:652b5f51319d 168
jamesheavey 58:a159cd976aca 169 while (pad.check_event(Gamepad::B_PRESSED) == false) { // while B is not pressed to return to main menu
jamesheavey 53:8e3da0b58fe9 170 lcd.clear();
jamesheavey 58:a159cd976aca 171 lcd.printString(" JOYSTICK ",0,2); // choose joystick
jamesheavey 58:a159cd976aca 172 lcd.printString(" TILT ",0,3); // choose tilt
jamesheavey 56:f9e586348e0b 173 lcd.printString(" >",0,pointer);
jamesheavey 53:8e3da0b58fe9 174 lcd.refresh();
jamesheavey 53:8e3da0b58fe9 175 wait(0.1);
jamesheavey 58:a159cd976aca 176 if (pad.check_event(Gamepad::L_PRESSED) && pointer > 2) { // if L is pressed and pointer isnt already on JOYSTICK, move it up one line
jamesheavey 50:3da51f34e253 177 pointer -= 1;
jamesheavey 53:8e3da0b58fe9 178 pad.tone(750.0,0.3);
jamesheavey 53:8e3da0b58fe9 179 wait(0.1);
jamesheavey 58:a159cd976aca 180 } else if (pad.check_event(Gamepad::R_PRESSED) && pointer < 3) { // if R is pressed and pointer isnt already on TILT, move it down one line
jamesheavey 50:3da51f34e253 181 pointer += 1;
jamesheavey 53:8e3da0b58fe9 182 pad.tone(750.0,0.3);
jamesheavey 53:8e3da0b58fe9 183 wait(0.1);
jamesheavey 50:3da51f34e253 184 }
jamesheavey 16:1761dfe801af 185
jamesheavey 58:a159cd976aca 186 if (pad.check_event(Gamepad::A_PRESSED)) { // if A is pressed, switch the tilt option accordingly
jamesheavey 56:f9e586348e0b 187 pad.tone(750.0,0.3);
jamesheavey 56:f9e586348e0b 188 wait(0.1);
jamesheavey 58:a159cd976aca 189 if (pointer == 2) { // if A is pressed on JOYSTICK, tilt = false
jamesheavey 57:d498dd835cfc 190 tilt = false;
jamesheavey 57:d498dd835cfc 191 }
jamesheavey 58:a159cd976aca 192 else if (pointer == 3) { // if A is pressed on TILT, tilt == true
jamesheavey 57:d498dd835cfc 193 tilt = true;
jamesheavey 57:d498dd835cfc 194 }
jamesheavey 58:a159cd976aca 195 }
jamesheavey 55:b7bde601c23e 196
jamesheavey 58:a159cd976aca 197 if (pad.check_event(Gamepad::B_PRESSED)) { // when B is pressed return to main menu
jamesheavey 56:f9e586348e0b 198 pad.tone(750.0,0.3);
jamesheavey 50:3da51f34e253 199 main_menu();
jamesheavey 16:1761dfe801af 200 }
jamesheavey 0:7d4d2023ed9c 201 }
jamesheavey 10:9f445faa892c 202 }
jamesheavey 10:9f445faa892c 203
jamesheavey 52:652b5f51319d 204 void how_to_play() {
jamesheavey 58:a159cd976aca 205 while (pad.check_event(Gamepad::B_PRESSED) == false) { // while B is not pressed to return to main menu display instruction on how to interact with the game
jamesheavey 50:3da51f34e253 206 lcd.clear();
jamesheavey 50:3da51f34e253 207 lcd.printString(" explain ",2,2);
jamesheavey 50:3da51f34e253 208 lcd.printString(" PRESS B ",1,4);
jamesheavey 50:3da51f34e253 209 lcd.refresh();
jamesheavey 53:8e3da0b58fe9 210 wait(0.1);
jamesheavey 50:3da51f34e253 211 }
jamesheavey 58:a159cd976aca 212 main_menu(); // when B is pressed, the loop is exited and main menu is entered once again
jamesheavey 58:a159cd976aca 213 }
jamesheavey 58:a159cd976aca 214
jamesheavey 58:a159cd976aca 215
jamesheavey 58:a159cd976aca 216 void main_game(bool tilt) {
jamesheavey 58:a159cd976aca 217 int fps = 8; // frames per second
jamesheavey 58:a159cd976aca 218 bool pause = false; // set pause screen to false
jamesheavey 58:a159cd976aca 219
jamesheavey 58:a159cd976aca 220 breakout.init(PADDLE_WIDTH,PADDLE_HEIGHT,BALL_SIZE,pad.read_pot()*3+2,prev_score); // init the objects
jamesheavey 58:a159cd976aca 221
jamesheavey 58:a159cd976aca 222 lcd.setBrightness(1);
jamesheavey 58:a159cd976aca 223
jamesheavey 58:a159cd976aca 224 Bitmap three(three_data, 48, 84); // assign the 3 sprite data
jamesheavey 58:a159cd976aca 225 Bitmap two(two_data, 48, 84); // assign the 2 sprite data
jamesheavey 58:a159cd976aca 226 Bitmap one(one_data, 48, 84); // assign the 1 sprite data
jamesheavey 58:a159cd976aca 227
jamesheavey 58:a159cd976aca 228 lcd.clear();
jamesheavey 58:a159cd976aca 229 three.render(lcd, 0, 0); // render the 3
jamesheavey 58:a159cd976aca 230 lcd.refresh();
jamesheavey 58:a159cd976aca 231 pad.tone(500.0,0.5);
jamesheavey 58:a159cd976aca 232 wait(1); // wait 1 second
jamesheavey 58:a159cd976aca 233
jamesheavey 58:a159cd976aca 234 lcd.clear();
jamesheavey 58:a159cd976aca 235 two.render(lcd, 0, 0); // render 2
jamesheavey 58:a159cd976aca 236 lcd.refresh();
jamesheavey 58:a159cd976aca 237 pad.tone(500.0,0.5);
jamesheavey 58:a159cd976aca 238 wait(1); // wait 1 second
jamesheavey 58:a159cd976aca 239
jamesheavey 58:a159cd976aca 240 lcd.clear();
jamesheavey 58:a159cd976aca 241 one.render(lcd, 0, 0); // render 1
jamesheavey 58:a159cd976aca 242 lcd.refresh();
jamesheavey 58:a159cd976aca 243 pad.tone(1000.0,1);
jamesheavey 58:a159cd976aca 244 wait(1); // wait 1 second
jamesheavey 58:a159cd976aca 245
jamesheavey 58:a159cd976aca 246 render(); // first draw the initial frame
jamesheavey 58:a159cd976aca 247 wait(1.0f/fps); // and wait for one frame period
jamesheavey 58:a159cd976aca 248
jamesheavey 58:a159cd976aca 249
jamesheavey 58:a159cd976aca 250 // game loop - read input, update the game state and render the display
jamesheavey 58:a159cd976aca 251 while (1) {
jamesheavey 58:a159cd976aca 252 breakout.read_input(pad,tilt);
jamesheavey 58:a159cd976aca 253 breakout.update(pad);
jamesheavey 58:a159cd976aca 254 render();
jamesheavey 58:a159cd976aca 255 if (breakout.check_goal(pad) == true) {
jamesheavey 58:a159cd976aca 256 flash_screen(lcd);
jamesheavey 58:a159cd976aca 257 }
jamesheavey 58:a159cd976aca 258 if (pad.check_event(Gamepad::BACK_PRESSED) == true) {
jamesheavey 58:a159cd976aca 259 pause = !pause;
jamesheavey 58:a159cd976aca 260 }
jamesheavey 58:a159cd976aca 261 while (pause == true) {
jamesheavey 58:a159cd976aca 262 lcd.clear();
jamesheavey 58:a159cd976aca 263 lcd.printString(" PAUSED ",0,2);
jamesheavey 58:a159cd976aca 264 lcd.refresh();
jamesheavey 58:a159cd976aca 265 if (pad.check_event(Gamepad::BACK_PRESSED) == true) {
jamesheavey 58:a159cd976aca 266 pause = !pause;
jamesheavey 58:a159cd976aca 267 }
jamesheavey 58:a159cd976aca 268 wait(1.0f/fps);
jamesheavey 58:a159cd976aca 269 }
jamesheavey 58:a159cd976aca 270 if (breakout.get_lives() == 0) {
jamesheavey 58:a159cd976aca 271 pad.leds_off(); //turns last led off (doesnt run through and update bored so last led doent turn off via lives leds
jamesheavey 58:a159cd976aca 272 end_screen();
jamesheavey 58:a159cd976aca 273 }
jamesheavey 58:a159cd976aca 274 if (breakout.get_num_left() == 0) {
jamesheavey 58:a159cd976aca 275 victory_screen();
jamesheavey 58:a159cd976aca 276 }
jamesheavey 58:a159cd976aca 277 wait(1.0f/fps);
jamesheavey 58:a159cd976aca 278 }
jamesheavey 50:3da51f34e253 279 }
jamesheavey 16:1761dfe801af 280
jamesheavey 10:9f445faa892c 281 void end_screen() {
jamesheavey 15:b867a6620f96 282 lcd.clear();
jamesheavey 38:3a077f0259df 283 lcd.printString(" RESTART? ",2,2);
jamesheavey 15:b867a6620f96 284 lcd.printString(" PRESS START ",1,4);
jamesheavey 15:b867a6620f96 285 lcd.refresh();
jamesheavey 15:b867a6620f96 286 pad.tone(750.0,0.3);
jamesheavey 15:b867a6620f96 287 wait(0.4);
jamesheavey 15:b867a6620f96 288
jamesheavey 15:b867a6620f96 289 pad.tone(300.0,0.3);
jamesheavey 15:b867a6620f96 290 wait(0.4);
jamesheavey 10:9f445faa892c 291
jamesheavey 10:9f445faa892c 292 while (pad.check_event(Gamepad::START_PRESSED) == false) {
jamesheavey 10:9f445faa892c 293 lcd.clear();
jamesheavey 48:966f2cf803ec 294 lcd.printString(" RESTART? ",2,2); //print score here
jamesheavey 10:9f445faa892c 295 lcd.printString(" PRESS START ",1,4);
jamesheavey 10:9f445faa892c 296 lcd.refresh();
jamesheavey 10:9f445faa892c 297 }
jamesheavey 49:31eb7807dbd3 298 title_screen();
jamesheavey 10:9f445faa892c 299 }
jamesheavey 10:9f445faa892c 300
jamesheavey 13:418a71b24b37 301 void victory_screen() {
jamesheavey 15:b867a6620f96 302 lcd.clear();
jamesheavey 43:81d22f68dfae 303 lcd.printString(" VICTORY! ",2,1);
jamesheavey 47:1d1a827be81b 304 lcd.printString(" CONT = START ",0,4); // print score here
jamesheavey 47:1d1a827be81b 305 lcd.printString(" MENU = BACK ",0,5);
jamesheavey 15:b867a6620f96 306 lcd.refresh();
jamesheavey 22:fa2e0b58043a 307 pad.tone(2500.0,0.1);
jamesheavey 22:fa2e0b58043a 308 wait(0.4);
jamesheavey 15:b867a6620f96 309
jamesheavey 22:fa2e0b58043a 310 pad.tone(2500.0,0.1);
jamesheavey 22:fa2e0b58043a 311 wait(0.2);
jamesheavey 15:b867a6620f96 312
jamesheavey 15:b867a6620f96 313 pad.tone(4000.0,0.6);
jamesheavey 15:b867a6620f96 314 wait(0.6);
jamesheavey 43:81d22f68dfae 315 while (pad.check_event(Gamepad::START_PRESSED) || pad.check_event(Gamepad::BACK_PRESSED) == false) {
jamesheavey 13:418a71b24b37 316 lcd.clear();
jamesheavey 43:81d22f68dfae 317
jamesheavey 43:81d22f68dfae 318 lcd.printString(" VICTORY! ",2,1);
jamesheavey 47:1d1a827be81b 319 lcd.printString(" CONT = START ",0,4);
jamesheavey 47:1d1a827be81b 320 lcd.printString(" MENU = BACK ",0,5);
jamesheavey 43:81d22f68dfae 321
jamesheavey 13:418a71b24b37 322 lcd.refresh();
jamesheavey 15:b867a6620f96 323
jamesheavey 43:81d22f68dfae 324 if (pad.check_event(Gamepad::START_PRESSED)) {
jamesheavey 47:1d1a827be81b 325 prev_score = breakout.get_prev_score();
jamesheavey 55:b7bde601c23e 326 main_game(tilt);
jamesheavey 43:81d22f68dfae 327 }
jamesheavey 43:81d22f68dfae 328 else if (pad.check_event(Gamepad::BACK_PRESSED)) {
jamesheavey 49:31eb7807dbd3 329 title_screen();
jamesheavey 43:81d22f68dfae 330 }
jamesheavey 13:418a71b24b37 331 }
jamesheavey 13:418a71b24b37 332 }
jamesheavey 13:418a71b24b37 333
jamesheavey 58:a159cd976aca 334 void flash_screen(N5110 &lcd) {
jamesheavey 58:a159cd976aca 335 lcd.setBrightness(0);
jamesheavey 58:a159cd976aca 336 wait(0.1);
jamesheavey 58:a159cd976aca 337 lcd.setBrightness(1);
jamesheavey 58:a159cd976aca 338 wait(0.1);
jamesheavey 58:a159cd976aca 339 lcd.setBrightness(0);
jamesheavey 58:a159cd976aca 340 wait(0.1);
jamesheavey 47:1d1a827be81b 341 lcd.setBrightness(1);
jamesheavey 58:a159cd976aca 342 wait(0.1);
jamesheavey 58:a159cd976aca 343 lcd.setBrightness(0);
jamesheavey 58:a159cd976aca 344 wait(0.1);
jamesheavey 58:a159cd976aca 345 lcd.setBrightness(1);
jamesheavey 58:a159cd976aca 346 wait(0.1);
jamesheavey 58:a159cd976aca 347 lcd.setBrightness(0);
jamesheavey 58:a159cd976aca 348 wait(0.1);
jamesheavey 58:a159cd976aca 349 lcd.setBrightness(1);
jamesheavey 58:a159cd976aca 350 }