Haoyan Zhang
/
el17h2z1
deemo1
Diff: mian.cpp
- Revision:
- 2:03cd3bb32511
- Parent:
- 1:8c48fb8ca5e0
- Child:
- 3:1db91ad3ab84
diff -r 8c48fb8ca5e0 -r 03cd3bb32511 mian.cpp --- a/mian.cpp Mon May 11 06:50:18 2020 +0000 +++ b/mian.cpp Tue May 12 08:01:52 2020 +0000 @@ -40,6 +40,7 @@ void update_game(UserInput input); void render(); void welcome(); +void victory(); void gameover(); void background(); void score(); @@ -60,11 +61,23 @@ Starcraft.update(pad); render(); wait(1.0f/fps); + if (Starcraft.find_score() == 20) { + break; + } } + score(); - gameover(); - wait(1); - goto S1; + if (Starcraft.find_score() == 20) { + victory(); + wait(1); + goto S1; + } + + else{ + gameover(); + wait(1); + goto S1; + } } // initialies all classes and libraries @@ -140,7 +153,7 @@ wait(2); lcd.clear(); - lcd.printString(" Good luck ",2,2); + lcd.printString(" Good luck! ",2,2); lcd.refresh(); wait(2); } @@ -158,6 +171,26 @@ wait(1.5); } +void victory() +{ + lcd.clear(); + lcd.printString(" Victory! ",2,2); + lcd.refresh(); + wait(2); + + lcd.clear(); + lcd.printString(" Press back ",1,3); + lcd.printString(" to play again ",1,4); + lcd.refresh(); + + while ( pad.check_event(Gamepad::START_PRESSED) == false && pad.check_event(Gamepad::BACK_PRESSED) == false) { + pad.leds_on(); + wait(0.1); + pad.leds_off(); + wait(0.1); + } +} + void gameover() { lcd.clear();