Meteor defense project

Dependencies:   N5110 mbed

Revision:
30:2e2d48cbfec3
Parent:
29:6632dd9c48d8
Child:
31:1c0e47931e84
--- a/Spawn/Spawn.cpp	Tue Apr 18 11:21:35 2017 +0000
+++ b/Spawn/Spawn.cpp	Tue Apr 18 21:50:14 2017 +0000
@@ -9,15 +9,52 @@
 {
 
 }
-void Spawn::init() {
-    healthA = 10;
-    healthC = 150;
-    healthDE = 20;
-    spawnRateA = 32; //32
-    spawnRateB = 1; //1
-    spawnRateC = 2; //2
-    spawnRateDE = 1; //1
+
+
+void Spawn::init(int w) {
+    statsA(w);
+    statsB(w);
+    statsC(w);
+    statsDE(w);
+    //printf("waveNumber = %d \n",w);
+    //printf("hA = %d, rA = %d, rB = %d, hC = %d, rC = %d, hDE = %d, rDE = %d \n"
+    //,A.health, A.spawnRate, B.spawnRate, C.health, C.spawnRate, DE.health, DE.spawnRate);
+    healthA = A.health;
+    healthC = C.health;
+    healthDE = DE.health;
+    spawnRateA = A.spawnRate; //32
+    spawnRateB = B.spawnRate; //1
+    spawnRateC = C.spawnRate; //2
+    spawnRateDE = DE.spawnRate; //1
 }
+Stats Spawn::statsA(int w) {
+    A.spawnRate = 32 + w;
+    A.health = 10 + 4 * w;
+    Stats A = {A.spawnRate, A.health};
+    return A;     
+}
+Stats Spawn::statsB(int w) {
+    if ( w % 2 == 0) { //every 2 wave, increase spawn rate of B by 1.
+        B.spawnRate = 1 + w;
+    }
+    B.health = 0;
+    Stats B = {B.spawnRate, B.health};
+    return B;     
+}
+Stats Spawn::statsC(int w) {
+    C.spawnRate = 3 + w;
+    C.health = 150 + 2 * w;
+    Stats C = {C.spawnRate, C.health};
+    return C;     
+}
+Stats Spawn::statsDE(int w) {
+    if ( w % 2 == 0) { //every 2 wave, increase spawn rate of DE by 1.
+        DE.spawnRate = 1 + DE.spawnRate;
+    }
+    DE.health = 15 + 2 * w ;
+    Stats DE = {DE.spawnRate, DE.health};
+    return DE;     
+}                
 void Spawn::randomizeSpawn(int Arr[][Rows], char cArr[][Rows]) {
         //there is 4 kind of different spawn - a, b, c and d/e.
         if (stopSpawnA == 1) { //spawn for this row
@@ -185,5 +222,3 @@
     //printf("char at Arr2[%d][%d] cleared for good. \n",x,y);
     }  
 }
-
-                
\ No newline at end of file