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.
Dependencies: mbed
Diff: main.cpp
- Revision:
- 10:961bf7a76f45
- Parent:
- 9:f88f3f50bbee
- Child:
- 11:4723e7f3f1d2
diff -r f88f3f50bbee -r 961bf7a76f45 main.cpp --- a/main.cpp Thu May 09 02:56:02 2019 +0000 +++ b/main.cpp Thu May 09 03:40:19 2019 +0000 @@ -37,6 +37,7 @@ void welcome(); void endgame(); void introduction(); +void fingersnap(); const int Avenger0[25][32] = { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }, @@ -125,19 +126,23 @@ { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }, }; -const int intro3[12][16] = { - { 0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0 }, - { 0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0 }, - { 0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0 }, - { 0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0 }, - { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0 }, - { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 }, - { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 }, - { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0 }, - { 0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0 }, - { 0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0 }, - { 0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0 }, - { 0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0 }, +const int intro3[16][18] = { + { 0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0 }, + { 0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0 }, + { 0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0 }, + { 0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0 }, + { 0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,0,0,0 }, + { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0 }, + { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0 }, + { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 }, + { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 }, + { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0 }, + { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0 }, + { 0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,0,0,0 }, + { 0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0 }, + { 0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0 }, + { 0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0 }, + { 0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0 }, }; ///////////// functions //////////////// @@ -151,13 +156,19 @@ render(); wait(1.0f/fps); // and wait for one frame period - while (eng.get_score() >= 0) { + while (1) { eng.read_input(pad); eng.update(pad); render(); wait(1.0f/fps); + if (eng.get_score() == 6) { + fingersnap(); + break; + } else if (eng.get_score() < 0) { + endgame(); + break; + } } - endgame(); } } @@ -172,7 +183,37 @@ } void welcome() { - + lcd.clear(); + lcd.printString("Eternity Stone",0,0); + lcd.printString("Start story",9,4); + lcd.drawSprite(25,8,25,32,(int *)Avenger0); + lcd.refresh(); + pad.tone(440.00,0.21); + wait(0.21); + pad.tone(587.3,0.63); + wait(0.63); + pad.tone(0.0,0.06); + wait(0.06); + pad.tone(587.3,0.63); + wait(0.63); + pad.tone(0.0,0.06); + wait(0.06); + pad.tone(587.3,0.63); + wait(0.63); + pad.tone(0.0,0.06); + wait(0.06); + pad.tone(587.3,0.42); + wait(0.42); + pad.tone(880.0,0.21); + wait(0.21); + pad.tone(784.0,1.40); + wait(1.40); + pad.tone(698.5,0.70); + wait(0.70); + pad.tone(659.3,0.70); + wait(0.70); + pad.tone(587.3,0.63); + wait(0.70); while (pad.check_event(Gamepad::START_PRESSED) == false) { lcd.clear(); lcd.printString("Eternity Stone",0,0); @@ -191,7 +232,7 @@ void introduction() { lcd.clear(); - lcd.printString("Five year",15,0); + lcd.printString("Five years",12,0); lcd.refresh(); wait(1.0); lcd.printString("Since Thanos",6,2); @@ -221,20 +262,20 @@ } while (pad.check_event(Gamepad::START_PRESSED) == false) { lcd.clear(); - lcd.printString("Use your",12,0); - lcd.printString("joystick to",15,1); + lcd.printString("Use your",18,0); + lcd.printString("joystick to",9,1); lcd.printString("send yourself",3,2); lcd.printString("to the right",6,3); - lcd.printString("Wormhole",6,4); + lcd.printString("Wormhole",18,4); lcd.drawSprite(0,40,8,84,(int *)intro0); lcd.refresh(); wait(0.5); lcd.clear(); - lcd.printString("Use your",12,0); - lcd.printString("joystick to",15,1); + lcd.printString("Use your",18,0); + lcd.printString("joystick to",9,1); lcd.printString("send yourself",3,2); lcd.printString("to the right",6,3); - lcd.printString("Wormhole",6,4); + lcd.printString("Wormhole",18,4); lcd.drawSprite(0,40,8,84,(int *)intro1); lcd.refresh(); wait(0.5); @@ -256,7 +297,7 @@ lcd.printString("line but",0,3); lcd.printString("pass thro.",12,4); lcd.printString("the gap",21,5); - lcd.drawSprite(54,16,12,16,(int *)intro3); + lcd.drawSprite(54,16,16,18,(int *)intro3); lcd.drawRect(77,0,2,18,FILL_BLACK); lcd.drawRect(77,30,2,18,FILL_BLACK); lcd.refresh(); @@ -268,7 +309,7 @@ lcd.printString("line but",0,3); lcd.printString("pass thro.",12,4); lcd.printString("the gap",21,5); - lcd.drawSprite(60,16,12,16,(int *)intro3); + lcd.drawSprite(60,16,16,18,(int *)intro3); lcd.drawRect(77,0,2,18,FILL_BLACK); lcd.drawRect(77,30,2,18,FILL_BLACK); lcd.refresh(); @@ -297,17 +338,59 @@ } void render() { - // clear screen, re-draw and refresh lcd.clear(); eng.draw(lcd); lcd.refresh(); } +void fingersnap() { + lcd.clear(); + lcd.printString("Congrat!!",15,1); + lcd.refresh(); + pad.tone(440.00,0.21); + wait(0.21); + pad.tone(587.3,0.63); + wait(0.63); + pad.tone(0.0,0.06); + wait(0.06); + pad.tone(587.3,0.63); + wait(0.63); + pad.tone(0.0,0.06); + wait(0.06); + pad.tone(587.3,0.63); + wait(0.63); + pad.tone(0.0,0.06); + wait(0.06); + pad.tone(587.3,0.42); + wait(0.42); + pad.tone(880.0,0.21); + wait(0.21); + pad.tone(784.0,1.40); + wait(1.40); + pad.tone(698.5,0.70); + wait(0.70); + pad.tone(659.3,0.70); + wait(0.70); + pad.tone(587.3,0.63); + wait(0.70); + while (pad.check_event(Gamepad::START_PRESSED) == false) { + lcd.printString("press start",9,4); + lcd.printString("to return",15,5); + lcd.refresh(); + pad.leds_on(); + wait(0.5); + pad.leds_off(); + wait(0.5); + } +} + void endgame() { lcd.clear(); - lcd.printString("Endgame",12,1); - lcd.refresh(); + lcd.printString("Mr.Stark",18,1); + lcd.printString("I don't feel",6,2); + lcd.printString("so good ...",9,3); + lcd.refresh(); pad.tone(587.3,0.63); wait(0.63); pad.tone(0.0,0.06); @@ -339,8 +422,10 @@ pad.tone(587.3,0.42); wait(0.42); while (pad.check_event(Gamepad::START_PRESSED) == false) { - lcd.printString("Endgame",12,1); + lcd.printString("press start",9,4); + lcd.printString("to return",15,5); lcd.refresh(); + wait(0.5); } } \ No newline at end of file