Meteor defense project

Dependencies:   N5110 mbed

Revision:
10:926b1f89c4f1
Parent:
9:4c4d787c7a8b
Child:
11:1c48fe71045c
--- a/GameEngine/GameEngine.cpp	Tue Mar 28 20:13:01 2017 +0000
+++ b/GameEngine/GameEngine.cpp	Tue Mar 28 21:15:18 2017 +0000
@@ -18,6 +18,7 @@
         spa.randomizeSpawn(Array1, Array2);
         spa.moveSpawn(Array1, Array2);
         spa.updateSpawn(Array1,Array2,lcd);
+        checkGameRule(lcd);
     } else {
         drawit -=0.5;
         spa.updateSpawn(Array1,Array2,lcd);        
@@ -27,16 +28,28 @@
     weap.laserDamage();
     weap.drawWeapon(pad, lcd);
     //draw a line for the laser when button is pressed
-    if (pad.buttonhold == 1) {
+    if (pad.buttonhold_A == 1) {
         //printf("hi, button is working \n");
         weap.weaponMath(pad);
         weap.drawLaser(Array1, lcd);
     }
 }
 
-void GameEngine::checkGameRule() {
+void GameEngine::checkGameRule(N5110 &lcd) {
     //the only way to lose is when the spawn reaches y = 46.
-    
+    for ( int x = 0; x < 84; x ++) {
+        if (Array1[x][46] > 0) {
+            while (1) {
+                lcd.clear();
+                lcd.printString("Game Over",10,3);
+                lcd.refresh();
+                wait(1.0);
+            }
+        }
+    }       
 }
-
-    
\ No newline at end of file
+void GameEngine::bomb(Gamepad &pad, N5110 &lcd) {
+    if (pad.check_event(Gamepad::L_PRESSED)) {
+        weap.drawBomb(pad, lcd);
+    }
+}
\ No newline at end of file