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:b939edd9b87c
- Parent:
- 9:dc13042b09f5
- Child:
- 11:0e6a221ad8a9
--- a/main.cpp Sun May 05 23:31:07 2019 +0000
+++ b/main.cpp Fri May 10 12:00:30 2019 +0000
@@ -30,23 +30,27 @@
///////////// prototypes ///////////////
void init();
void welcome();
+void finish();
void render();
///////////// functions ////////////////
int main() {
- int fps = 10; // frames per second
+ int fps = 9; // frames per second
init();
welcome();
// game loop - read input, update the game state and render the display
while(1) {
- // engine.read_input(gamepad);
+ engine.read_input(gamepad, 1.0f/fps);
engine.update(gamepad, lcd, 1.0f/fps);
+ if ( engine.get_lap() == 1) break;
render();
wait(1.0f/fps);
}
+
+ finish();
}
@@ -68,10 +72,28 @@
void welcome() {
Menu menu;
- //menu.intro(lcd, gamepad);
- while (menu.startMainMenu(lcd, gamepad) == 1) {
- //menu.displayControls(lcd, gamepad);
- };
+ menu.intro(lcd, gamepad);
+ menu.startMainMenu(lcd, gamepad);
+
+}
+// display lap time and finish
+void finish() {
+ clearScreen(lcd);
+ if(engine.get_lap_time() < 37) {
+ printSoundString(lcd, gamepad, "Great job", 0, 0, 876, 0.1);
+ printSoundString(lcd, gamepad, "lap time < 37s", 0, 1, 876, 0.1);
+ printSoundString(lcd, gamepad, "The planet is ", 0, 2, 876, 0.1);
+ printSoundString(lcd, gamepad, "safe", 0, 3, 876, 0.1);
+ }
+ if(engine.get_lap_time() > 37) {
+ printSoundString(lcd, gamepad, "Game over", 0, 1, 876, 0.1);
+ printSoundString(lcd, gamepad, "lap time > 37s", 0, 1, 876, 0.1);
+ printSoundString(lcd, gamepad, "The delivery", 0, 2, 876, 0.1);
+ printSoundString(lcd, gamepad, "failed and the ", 0, 3, 876, 0.1);
+ printSoundString(lcd, gamepad, "planet will", 0, 4, 876, 0.1);
+ printSoundString(lcd, gamepad, "be destroyed", 0, 5, 876, 0.1);
+ }
+ wait(60);
}
// this function draws each frame on the LCD
void render() {