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:
- 11:b25874e7efe4
- Parent:
- 10:279d3775d52c
- Child:
- 12:d3eef5ea3f43
--- a/main.cpp Sun May 06 22:42:49 2018 +0000
+++ b/main.cpp Mon May 07 00:10:25 2018 +0000
@@ -32,6 +32,7 @@
void renderMenu();
void welcome();
void transition();
+float setDif();
///////////// functions ////////////////
int main()
@@ -40,7 +41,7 @@
welcome();
transition();
-
+
// game loop - read input, update the game state and render the display
while (1) {
if (!mainMenu.started()) { //menu logic and rendering
@@ -83,14 +84,11 @@
void renderGame()
{
-
- int fps = 8; // frames per second
-
// clear screen, re-draw and refresh
lcd.clear();
gameEngine.draw(lcd);
lcd.refresh();
- wait(1.0f/fps);
+ wait(setDif());
}
void renderMenu()
@@ -103,7 +101,8 @@
}
void transition()
-{ //transition animation between modes to stop 'ghosting' of inputs
+{
+ //transition animation between modes to stop 'ghosting' of inputs
for (int i = 0; i <= 11; i++) {
for (int j = 0; j <= 21; j++) {
lcd.drawRect(j*4,i*4,4,4,FILL_BLACK);
@@ -114,3 +113,23 @@
}
+float setDif()
+{
+ int _dif = mainMenu.getDif();
+
+ if (_dif == 1) {
+ return 1.0f/4;
+ } else if (_dif == 2) {
+ return 1.0f/8;
+ } else if (_dif == 3) {
+ return 1.0f/12;
+ } else if (_dif == 1) {
+ int _delta = gameEngine.getScore();
+ if (_delta < 38) {
+ return ((1.0f/(_delta/2)) + 6);
+ } else {
+ return (1.0f/25);
+ }
+ }
+ return 1.0f;
+}