Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: main.cpp
- Revision:
- 103:f9f69944a850
- Parent:
- 102:4946a6b47c78
- Child:
- 104:c2d49c4f3e06
diff -r 4946a6b47c78 -r f9f69944a850 main.cpp --- a/main.cpp Tue May 07 17:34:18 2019 +0000 +++ b/main.cpp Tue May 07 18:17:37 2019 +0000 @@ -40,6 +40,8 @@ void save_hi_score(int hi_score); int get_hi_score(); bool compare_to_hi_score(int score); +void print_hi_score(int col,int row); +void flash_hi_score(); Bitmap breakwhite(breakwhite_data, 48, 84); // assign the title screen sprites Bitmap breakblack(breakblack_data, 48, 84); @@ -119,6 +121,8 @@ lcd.printString(" START ",0,1); // start game with default as joystick lcd.printString(" SETTINGS ",0,2); // choose between joystick and tilt lcd.printString(" HOW TO PLAY ",0,3); // brief text on how to do stuff + lcd.printString("HI-SCORE: ",0,5); + print_hi_score(60,5); lcd.refresh(); wait(0.3); @@ -129,6 +133,8 @@ lcd.printString(" START ",0,1); // start game with default as joystick lcd.printString(" SETTINGS ",0,2); // choose between joystick and tilt lcd.printString(" HOW TO PLAY ",0,3); // brief text on how to do stuff + lcd.printString("HI-SCORE: ",0,5); + print_hi_score(60,5); lcd.printString(" >",0,pointer); lcd.refresh(); wait(0.1); @@ -361,13 +367,7 @@ } if (compare_to_hi_score(bonus+breakout.get_score()) == true) { - lcd.clear(); - lcd.printString(" FUCK YEAH ",2,3); - char buffer1[14]; - sprintf(buffer1,"%2d",get_hi_score()); - lcd.printString(buffer1,WIDTH/2 - 12,2); - lcd.refresh(); - wait(3); + void flash_hi_score(); } lcd.clear(); @@ -379,9 +379,9 @@ char buffer2[14]; sprintf(buffer2,"%2d",bonus); lcd.printString(buffer2,WIDTH/2 + 10,3); - lcd.printString(" BONUS: ",2,3); + lcd.printString(" BONUS: ",2,3); - lcd.printString(" VICTORY! ",2,1); + lcd.printString(" VICTORY! ",2,0); lcd.printString(" CONT = START ",0,4); // print score here lcd.printString(" MENU = BACK ",0,5); lcd.refresh(); @@ -397,7 +397,7 @@ while (pad.check_event(Gamepad::START_PRESSED) || pad.check_event(Gamepad::BACK_PRESSED) == false) { lcd.clear(); - lcd.printString(" VICTORY! ",2,1); + lcd.printString(" VICTORY! ",2,0); lcd.printString(" CONT = START ",0,4); lcd.printString(" MENU = BACK ",0,5); @@ -413,10 +413,10 @@ char buffer2[14]; sprintf(buffer2,"%2d",bonus); - lcd.printString(buffer2,WIDTH/2 + 8,3); - lcd.printString(" BONUS:",2,3); + lcd.printString(buffer2,WIDTH/2 + 10,3); + lcd.printString(" BONUS:",2,3); - lcd.printString(" VICTORY! ",2,1); + lcd.printString(" VICTORY! ",2,0); lcd.printString(" CONT = START ",0,4); // print score here lcd.printString(" MENU = BACK ",0,5); lcd.refresh(); @@ -521,4 +521,56 @@ return false; } } - \ No newline at end of file + +void print_hi_score(int col,int row) +{ + char buffer[14]; + sprintf(buffer,"%2d",get_hi_score()); + lcd.printString(buffer,col,row); + +} + +void flash_hi_score() +{ + lcd.clear(); + lcd.printString(" NEW ",0,2); + lcd.printString(" HI-SCORE! ",0,3); + lcd.refresh(); + + pad.tone(2500.0,0.2); + wait(0.2); + + pad.tone(4000.0,0.4); + wait(1); + + lcd.clear(); + print_hi_score(30,3); + lcd.refresh(); + + pad.tone(2500.0,0.2); + wait(0.2); + + pad.tone(4000.0,0.4); + wait(1); + + lcd.clear(); + lcd.printString(" NEW ",0,2); + lcd.printString(" HI-SCORE! ",0,3); + lcd.refresh(); + + pad.tone(2500.0,0.2); + wait(0.2); + + pad.tone(4000.0,0.4); + wait(1); + + lcd.clear(); + print_hi_score(30,3); + lcd.refresh(); + + pad.tone(2500.0,0.2); + wait(0.2); + + pad.tone(4000.0,0.4); + wait(1); +} \ No newline at end of file