Meteor defense project

Dependencies:   N5110 mbed

Revision:
28:450ab72fabdc
Parent:
17:53aedd20155a
Child:
29:6632dd9c48d8
--- a/main.cpp	Fri Apr 14 21:43:05 2017 +0000
+++ b/main.cpp	Mon Apr 17 18:22:16 2017 +0000
@@ -14,33 +14,66 @@
 
 
 
-int gamefps = 15;
+
+int gamefps = 3;
+
+Ticker waveCompleteTicker; 
+int setTicker;
+int waveComplete_flag;
+void waveComplete_isr();
+char wave[10]; 
+int waveNumber;
+
+
 void init();
 void render();
 
+
 int main()
 {
-
+    setTicker = 1; //set the ticker.
     init();
     while (true) {
-        game.update(pad, lcd);
+        if (setTicker == 1) { 
+            sprintf(wave, "wave %d", waveNumber + 1); //+1 because initially waveNumber = 0
+            lcd.printString(wave,10,3);
+            render();
+            wait(2.0);
+            waveCompleteTicker.attach(&waveComplete_isr,2);
+            setTicker = 0; //clear set ticker flag
+        }
+        //game.update(pad, lcd); //this is the game
+        while(waveComplete_flag == 1) {
+            waveCompleteTicker.detach();
+            lcd.printString("60 seconds",10,3);
+            lcd.printString("Start to Upgrade",1,5);
+            render();
+            game.weapUpgrade(pad, lcd);
+            if (game.done == 1) {
+                waveComplete_flag = 0; //get out of while loop
+                setTicker = 1; //continue the game
+                game.done = 0;
+                printf("i got out");
+            }
+        }
         render();
     }
 }
 
-void init()
-{
+void init() {
     // need to initialise LCD and Gamepad 
     lcd.init();
     pad.init();
     game.init();
     // initialise the game
 }
-
-void render()
-{
+void render() {
     // clear screen, re-draw and refresh
     lcd.refresh();
     wait(1.0/gamefps);
     lcd.clear(); 
+}
+void waveComplete_isr() {
+    waveComplete_flag = 1;
+    waveNumber += 1;
 }
\ No newline at end of file