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:
- 14:cf4a32245152
- Parent:
- 13:00bbb0612e97
- Child:
- 15:658f1216ee84
--- a/main.cpp Fri May 04 23:26:17 2018 +0000 +++ b/main.cpp Sun May 06 16:17:41 2018 +0000 @@ -30,22 +30,28 @@ int main() { //game will excute if all tests passed - #ifdef ALL_TESTS_H +#ifdef ALL_TESTS_H int failures = Run_tests(); if(failures > 0) return failures; - #endif - +#endif + int fps = 8; // frames per second int sleep=0; init(); // initialise welcome(); // display welcome screen till the user press start to start the game + + //debugging + printf("\n....THE GAME STARTED :)..... \n\n"); render(); // drawing the initial frame wait(1.0f/fps); // wait for one frame period - // game loop executes untill check_gameOver() function return 1 to end the game - while (game.check_gameOver()!=1) { + + // game loop executes + while (1) { + + // green LEDs turn on and red LEDs turn off g_pad.led(1, 0); g_pad.led(4, 0); @@ -59,6 +65,8 @@ while(g_pad.check_event(Gamepad::BACK_PRESSED) == true || sleep ==1) { + printf("Waiting to contienue.....\n"); + sleep=1; // green LEDs turn off and red LED turn on g_pad.led(1, 2); @@ -74,9 +82,23 @@ break; } } + if (game.check_gameOver()==1) { // if check_gameOver() function return 1 gameOver screen will be showen + //debugging + printf("\n\n ....End of the game :)..... \n\n"); + + lcd.clear(); + gameOver(); //game over screen will be shown with travelling period that has been reached + + // reset to play again + game.reset_gameOver(); + init(); + render(); + + //debugging + printf("\n\n ....playing the game again :)..... \n\n"); + + } } - lcd.clear(); - gameOver(); //game over screen show up with the maximum secs that has been reached } @@ -120,11 +142,13 @@ // game over screen after the end of the game void gameOver() { - + //game over secreen will be showen until start button is pressed + while ( g_pad.check_event(Gamepad::START_PRESSED) == false) { lcd.printString(" Game Over!! ",0,1); //print the maximum recorded seconds game.print_travel_time(lcd); lcd.refresh(); + } }