Faizan and Pages fun little game

Dependencies:   4DGL-uLCD-SE mbed SDFileSystem wave_player

Revision:
9:f2ee3ef97af1
Parent:
8:b2df3588d8e0
Child:
10:75e221ead102
--- a/main.cpp	Mon Oct 31 04:26:48 2016 +0000
+++ b/main.cpp	Mon Oct 31 04:44:12 2016 +0000
@@ -1,5 +1,7 @@
 #include "mbed.h"
 #include "uLCD_4DGL.h"
+#include "SongPlayer.h"
+#include "NavSwitch.h"
 #include "food.h"
 #include "stack.h"
 #include <ctime>
@@ -22,6 +24,8 @@
 #define BROWN 0xf4a460
 
 uLCD_4DGL lcd(p9,p10,p11);
+SongPlayer speaker(p26);
+Nav_Switch myNav(p20, p19, p18, p17, p16); // pin order on Sparkfun breakout
 vector<Food> foods;
 Food * collided;
 
@@ -131,6 +135,11 @@
 
 void updateScore(int sandwichSize) {
     char scoreString[2];   // max 2-digit score
+    // C#, D#, F, A, D, E, F#, A#, _, A, Bb, B, C
+    float notes[14] = {554.4, 622.3, 698.5, 880, 587.3, 659.3, 740, 932.3, 0, 440, 466.2, 493.9, 523.3, 0};
+    float times[14] = {0.24, 0.24, 0.24, 0.24, 0.24, 0.24, 0.24, 0.24, 0.48, 0.48, 0.48, 0.48, 0.48, 0};
+
+    speaker.PlaySong(notes, times);
     score += sandwichSize;
     score = (score > 99) ? score - 100 : score; // score rollover
     sprintf(scoreString, "%d", score); // keep score as a char string
@@ -138,6 +147,12 @@
 }
 
 void drawLives() {
+    // G, D, _, D, D, C, B, G, E, _, E, C, _
+    float notes[13] = {195.9, 293.6, 0, 293.6, 293.6, 261.6, 246.9, 195.9, 164.8, 0, 164.8, 130.8, 0};
+    float times[13] = {0.24, 0.24, 0.24, 0.24, 0.32, 0.32, 0.32, 0.24, 0.24, 0.24, 0.24, 0.24, 0};
+
+    speaker.PlaySong(notes, times);
+
     if (lives < 3) {
         lcd.filled_circle(118, 100, 3, BLACK); // erase the life symbol
     }