Meteor defense project

Dependencies:   N5110 mbed

Revision:
1:f5cda0674f24
Parent:
0:5fbc0fbc9d30
Child:
2:2c60c92bf65b
--- a/Spawn/Spawn.cpp	Mon Mar 20 09:15:57 2017 +0000
+++ b/Spawn/Spawn.cpp	Mon Mar 20 22:06:50 2017 +0000
@@ -1,2 +1,60 @@
+#include "Spawn.h"
 
+Spawn::Spawn()
+{
+
+}
+
+Spawn::~Spawn()
+{
+
+}
+
+void Spawn::randomizeSpawn() {
+    
+    if (stopSpawn ==0) {
+        stopSpawn = 1;
+        for ( int x = 0; x < Cols; x++) {
+            //30% chance of spawning
+            bool TrueFalse = (rand() % 100) < 30;
+            if (TrueFalse) {
+                //spawning from the top of the screen
+                spawnArray[x][0] = 1;
+                
+                printf("spawn set at x = is %d \n",x);
+            }
+        }
+        printf("at x=2, y=0. value = %d \n",spawnArray[2][0]);
+    } else {
+        stopSpawn = 0;
+    }
+    
+}
+void Spawn::moveSpawn(int array[Cols][Rows]) {
+    //scan through the whole array
+    printf("x=2,y =0. value = %d \n",array[2][0]);
+    for ( int x = 0; x < Cols; x++) {
+        for ( int y = 0; y < Rows; y++) {
+            if (array[x][y] == 1) {
+                //move it down a row
+                array[x][y+1] = 1;
+                array[x][y] = 0;       
+            }
+        }
+    }
+    printf("at x=2, y=47. number is =%d \n",array[2][47]);  
+}
+
+void Spawn::updateSpawn(int array[Cols][Rows], N5110 &lcd) {
+    for ( int x = 0; x < 83; x++) {
+        for ( int y = 0; y < 45; y++) {
+            if (array[x][y] == 1) {
+                lcd.setPixel(x,y);
+            }
+        }
+    }
+}
+
+                
+    
     
\ No newline at end of file