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: Game/Game.cpp
- Revision:
- 16:64cd7bc094f9
- Parent:
- 15:8fbbdefbe720
- Child:
- 17:3c9672c6e532
--- a/Game/Game.cpp Sun Mar 31 14:56:55 2019 +0000 +++ b/Game/Game.cpp Sun Mar 31 18:05:01 2019 +0000 @@ -1,6 +1,7 @@ #include "Game.h" Game::Game(){ + playing = true; score = 0; gamepad.init(); renderer.init(); @@ -20,12 +21,30 @@ if(playing){ score++; } + else{ + if(gamepad.check_event(Gamepad::Y_PRESSED) == true){ + selection = true; + } + else if(gamepad.check_event(Gamepad::A_PRESSED) == true){ + selection = false; + } + if (selection == true && gamepad.check_event(Gamepad::B_PRESSED) == true){ + playing = true; + } + else if(selection == false && gamepad.check_event(Gamepad::B_PRESSED) == true){ + break; + } + } renderer.drawHorizon(coord.x/15); for (int c = 0; c< cubeVector.size(); c++) { if(playing){ - cubeVector[c].translate(-coord.x*1.4,0,-3); + if(score < 2500) + cubeVector[c].translate(-coord.x*1.4,0,-2.5-(double)score/1000); + else{ + cubeVector[c].translate(-coord.x*1.4,0,(double)-5); + } } for (int i = 0; i < 6; i++){ faceVector.push_back(cubeVector[c].getFace(i)); @@ -61,14 +80,22 @@ //wait_ms(1000/1); } + if(!playing){ + deathScreen(); + } char buf[10]; sprintf(buf, "%d", score); - renderer.print(buf); + renderer.print(buf, 0, 0); memset(buf, 0, sizeof buf); renderer.refresh(); faceVector.clear(); - + wait_ms(1000/30); } } + +void Game::deathScreen(){ + //int selection = 1; + renderer.drawDeathScreen(selection); +} \ No newline at end of file