Meteor defense project

Dependencies:   N5110 mbed

Revision:
32:580d74825810
Parent:
31:1c0e47931e84
Child:
33:61c69c46a941
--- a/Spawn/Spawn.cpp	Wed Apr 19 21:42:46 2017 +0000
+++ b/Spawn/Spawn.cpp	Fri Apr 21 12:00:17 2017 +0000
@@ -9,14 +9,18 @@
 {
 
 }
-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) {
+    healthA = 7 + w * 2;
+    healthC = 150 + w * 5;
+    healthDE = 20 + w ;
+    spawnRateA = 32 + w; //32
+    spawnRateB = 1 + w / 2; //1
+    spawnRateC = 1 + w; //2
+    spawnRateDE = 1 + w/ 2; //1
+    //randomise the seed. To get different spawn pattern all the time.
+    int t = time(NULL);
+    //printf("t = %d \n",t);
+    srand(t);
 }
 void Spawn::randomizeSpawn(int Arr[][Rows], char cArr[][Rows]) {
         //there is 4 kind of different spawn - a, b, c and d/e.
@@ -37,7 +41,7 @@
     for ( int x = 0; x < Cols; x++) {
         //32/200 chance of spawning for A.
         //can depends on level
-        bool TrueFalseA = (rand() % 200) < spawnRateA;
+        bool TrueFalseA = (rand() % 220) < spawnRateA;
         if (TrueFalseA) {
             //spawning from the top of the screen
             Arr[x][0] = healthA;
@@ -47,7 +51,7 @@
     }    
 }
 void Spawn::spawnB(int x, int Arr[][Rows],char cArr[][Rows]) {
-    bool TrueFalseB = (rand() % 200) < spawnRateB;
+    bool TrueFalseB = (rand() % 220) < spawnRateB;
     if (TrueFalseB) {
         Arr[x][0] = 100000;
         cArr[x][0] = 'b';
@@ -55,7 +59,7 @@
 }
 void Spawn::spawnC(int Arr[][Rows],char cArr[][Rows]) {
     for ( int x = 0; x < Cols; x++) {
-    bool TrueFalseC = (rand() % 200) < spawnRateC;
+    bool TrueFalseC = (rand() % 220) < spawnRateC;
         if (TrueFalseC) {
             Arr[x][1] = healthC;
             cArr[x][1] = 'c';
@@ -65,7 +69,7 @@
     }
 }
 void Spawn::spawnDE(int x, int Arr[][Rows], char cArr[][Rows]) {
-    bool TrueFalseD = (rand() % 201) < spawnRateDE;
+    bool TrueFalseD = (rand() % 220) < spawnRateDE;
     if (TrueFalseD) {
         bool LeftRightD = (rand() % 10) <5; //its a 50-50 chance 
         if (LeftRightD) {