Faizan and Pages fun little game

Dependencies:   4DGL-uLCD-SE mbed SDFileSystem wave_player

Revision:
5:d832d2d67411
Parent:
4:c00da0b158c4
Child:
7:7cbff8cf583b
Child:
8:b2df3588d8e0
--- a/main.cpp	Mon Oct 31 02:58:10 2016 +0000
+++ b/main.cpp	Mon Oct 31 03:09:56 2016 +0000
@@ -29,6 +29,8 @@
 int indexToRemove;
 
 bool collisionCheck();
+void updateScore(int);
+void drawLives();
 
 int main() {
     
@@ -41,7 +43,12 @@
     clk = clk2 = 0;
     sandwich.draw();
     
-    lcd.line(120, 1, 120, 128, WHITE);
+    lcd.line(108, 1, 108, 128, WHITE);
+    
+    // inital lives
+    lcd.filled_circle(118, 80, 3, YELLOW); // x, y, radius, color
+    lcd.filled_circle(118, 90, 3, YELLOW);
+    lcd.filled_circle(118, 100, 3, YELLOW);
     
     while(lives) {
         if (!left) {
@@ -114,3 +121,22 @@
         // return true
 }
 
+void updateScore(int sandwichSize) {
+    char scoreString[2];   // max 2-digit score
+    score += sandwichSize;
+    score = (score > 99) ? score - 100 : score; // score rollover
+    sprintf(scoreString, "%d", score); // keep score as a char string
+    lcd.text_string(scoreString, 16, 1, FONT_7X8, WHITE); // 16 chars over, 1 down
+}
+
+void drawLives() {
+    if (lives < 3) {
+        lcd.filled_circle(118, 100, 3, BLACK); // erase the life symbol
+    }
+    else if (lives < 2) {
+        lcd.filled_circle(118, 108, 3, BLACK);
+    }
+    else if (lives < 1) {
+        lcd.filled_circle(118, 116, 3, BLACK);
+    }   
+}