Meteor defense project

Dependencies:   N5110 mbed

Revision:
26:140515d80457
Parent:
25:edd6a95607b1
Child:
27:d4926f19c12a
--- a/GameEngine/GameEngine.cpp	Thu Apr 13 22:21:02 2017 +0000
+++ b/GameEngine/GameEngine.cpp	Fri Apr 14 15:42:37 2017 +0000
@@ -10,27 +10,22 @@
 
 }
 void GameEngine::init() {
-    _d1.droneInit(20, 46, 0);
-    _d2.droneInit(62, 46, 83);   
+    _d1.droneInit(20, 46, 0, 42); //drone1 is taking left side pixel 0 to 42.
+    _d2.droneInit(62, 46, 42, 84); //drone2 is taking right side pixel 42 to 84;
     weap.init();
     spa.init();
     //printf("init completed \n");
 }
 void GameEngine::update(Gamepad &pad, N5110 &lcd) {
-    //_d1.drone(Array2, charArray2, lcd);
-    //_d2.drone(Array2, charArray2, lcd);
+    _d1.droneLeftSide(Array2, charArray2, lcd);
+    _d2.droneLeftSide(Array2, charArray2, lcd);
     drawSpawn(lcd); 
     drawLaserPlayer(pad, lcd);
     bombAndShield(pad, lcd);
 }
 void GameEngine::drawSpawn(N5110 &lcd){
-    //spawning every 2 second, moving spawn at every 1 seconds when fps = 15 & drawit=30. 
-    //It changes depending on the game FPS. 
-    for (int x = 0; x < Cols; x++) {
-        for (int y = 0; y < Rows; y++) {
-            spa.deleteChar(x, y, Array2, charArray); //clean up on the array if the spawn dies after taking damage.
-        }
-    }    
+    updateArray(); //clean up & update the array after the spawn took damage.
+    //spa.updateSpawn(Array, Array2, charArray, charArray2, lcd); //clean up on the array if the spawn dies after taking damage.
     if (drawit == 0) { //DONT FORGET TO CHANGE THIS TO TICKER. MORE EFFICIENT.
         drawit = 30;
         spa.randomizeSpawn(Array, charArray);
@@ -88,5 +83,14 @@
             pad.buttonhold_B = 1;
         }
     }
-    weap.shieldMeter(lcd);
+    weap.shieldMeter(lcd); 
+}
+void GameEngine::updateArray() { //clean up tool
+    for (int x = 0; x < Cols; x++) {
+        for (int y = 0; y < Rows; y++) {
+            Array[x][y] = Array2[x][y];
+            //printf(" Array[%d][%d] = %d \n",x,y,Array2[x][y]);
+            spa.deleteChar(x, y, Array, charArray2);
+        }
+    }    
 }
\ No newline at end of file