Faizan and Pages fun little game
Dependencies: 4DGL-uLCD-SE mbed SDFileSystem wave_player
Diff: main.cpp
- Revision:
- 7:7cbff8cf583b
- Parent:
- 5:d832d2d67411
--- a/main.cpp Mon Oct 31 03:09:56 2016 +0000 +++ b/main.cpp Mon Oct 31 04:05:14 2016 +0000 @@ -21,8 +21,8 @@ using namespace std; Stack sandwich(64,&lcd); -DigitalIn right(p19); -DigitalIn left(p20); +DigitalIn right(p21); +DigitalIn left(p22); int score, lives; float clk, clk2; Timer t; @@ -50,6 +50,8 @@ lcd.filled_circle(118, 90, 3, YELLOW); lcd.filled_circle(118, 100, 3, YELLOW); + updateScore(0); + while(lives) { if (!left) { sandwich.move(-1); @@ -60,10 +62,10 @@ collided->erase(); if (collided->isBad) { lives--; - // lifeLost() + drawLives(); // make a noise!1111 } else if (collided->typeOfFood == BREAD) { - // updateScore(sandwich.size()); // add the points to the overall score + updateScore(sandwich.size()); // add the points to the overall score sandwich.clear(); // should redraw // make a noise!!11 } else { @@ -74,17 +76,17 @@ } // every 3 seconds add new food! use timer. float curr = t.read(); - if (curr - clk >= 3.0) { + if (curr - clk >= 5.0) { clk = curr; // lcd.printf(" new "); - int x = rand()%110+1; + int x = rand()%90+1; int type = rand()%7+1; Food item(type, x, &lcd); foods.push_back(item); // add new food } // every .2 second each food should fall a lil bit! use timer. - if (curr - clk2 >= 0.2) { + if (curr - clk2 >= 0.1) { clk2 = curr; // lcd.printf(" fall "); for (int i = 0; i < foods.size(); i++) { @@ -94,7 +96,7 @@ // each food should fall a lil bit! } } - + lcd.cls(); lcd.printf("Your score is: %i", score); }