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.
Diff: main.cpp
- Revision:
- 12:d3eef5ea3f43
- Parent:
- 11:b25874e7efe4
- Child:
- 13:81573be8fac6
--- a/main.cpp Mon May 07 00:10:25 2018 +0000
+++ b/main.cpp Mon May 07 18:06:50 2018 +0000
@@ -32,6 +32,7 @@
void renderMenu();
void welcome();
void transition();
+void reset();
float setDif();
///////////// functions ////////////////
@@ -47,7 +48,11 @@
if (!mainMenu.started()) { //menu logic and rendering
mainMenu.read_input(pad);
mainMenu.update();
+ gameEngine.setLvl(mainMenu.getLvl());
renderMenu();
+ } else if (gameEngine.getGameOver()) { //resets the game once a game over state has been reached
+ gameEngine.gameOverScreen(lcd);
+ reset();
} else { //game logic and rendering
gameEngine.read_input(pad);
gameEngine.update(pad);
@@ -82,6 +87,12 @@
}
+void reset()
+{
+ mainMenu.init();
+ gameEngine.init();
+}
+
void renderGame()
{
// clear screen, re-draw and refresh
@@ -123,7 +134,7 @@
return 1.0f/8;
} else if (_dif == 3) {
return 1.0f/12;
- } else if (_dif == 1) {
+ } else if (_dif == 4) {
int _delta = gameEngine.getScore();
if (_delta < 38) {
return ((1.0f/(_delta/2)) + 6);