Meteor defense project

Dependencies:   N5110 mbed

Revision:
9:4c4d787c7a8b
Parent:
7:3be4369131c6
Child:
13:38cbce17d7d7
--- a/Spawn/Spawn.cpp	Tue Mar 28 11:38:13 2017 +0000
+++ b/Spawn/Spawn.cpp	Tue Mar 28 20:13:01 2017 +0000
@@ -15,12 +15,12 @@
     if (stopSpawn ==0) {
         stopSpawn = 1;
         for ( int x = 0; x < Cols; x++) {
-            //30% chance of spawning
+            //10% chance of spawning
             //can depends on level 
-            bool TrueFalse = (rand() % 100) < 20;
+            bool TrueFalse = (rand() % 100) < 10;
             if (TrueFalse) {
                 //spawning from the top of the screen
-                Arr1[x][0] = 1;
+                Arr2[x][0] = 1;
                 //printf("spawn set at x = is %d \n",x);
             }
         }
@@ -35,11 +35,11 @@
     //scan through the whole array
     for ( int x = 0; x < Cols; x++) {
         for ( int y = 0; y < Rows; y++) {
-            if (Arr1[x][y] > 0) {
+            if (Arr2[x][y] > 0) {
                 //move it down a row
-                Arr2[x][y+1] = Arr1[x][y];       
+                Arr1[x][y+1] = Arr2[x][y];       
             } else {
-                Arr2[x][y+1] = 0;
+                Arr1[x][y+1] = 0;
             }
         }
     }
@@ -49,12 +49,12 @@
 void Spawn::updateSpawn(int Arr1[][Rows], int Arr2[][Rows],N5110 &lcd) {
     for ( int x = 0; x < Cols; x++) {
         for ( int y = 0; y < Rows; y++) {
-            if (Arr2[x][y] > 0) {
+            if (Arr1[x][y] > 0) {
                 lcd.setPixel(x,y);
                 //to update array1 
-                Arr1[x][y] = Arr2[x][y];
+                Arr2[x][y] = Arr1[x][y];
             } else {
-                Arr1[x][y] = 0;
+                Arr2[x][y] = 0;
             }
         }
     }