JianWei Lee
/
project_game
Meteor defense project
Diff: Spawn/Spawn.cpp
- Revision:
- 39:f92b93efbc72
- Parent:
- 34:6ac9541d4c31
- Child:
- 40:3a0c66a0e10e
--- a/Spawn/Spawn.cpp Mon Apr 24 23:30:54 2017 +0000 +++ b/Spawn/Spawn.cpp Tue Apr 25 22:26:14 2017 +0000 @@ -12,7 +12,7 @@ void Spawn::init(int w) { A.health = 7 + 2 * w; A.spawnRate = 35 + w; - B.health = 0; + B.health = 1000; //health B wont change B.spawnRate = 1 + w / 2; C.health = 150 + w * 5; C.spawnRate = 1 + w; @@ -21,9 +21,8 @@ //randomise the seed. To get different spawn pattern all the time. int t = time(NULL); //printf("t = %d \n",t); - srand(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. if (stopSpawnA == 1) { //spawn spawnA for this row @@ -55,7 +54,7 @@ void Spawn::spawnB(int x, int Arr[][Rows],char cArr[][Rows]) { bool TrueFalseB = (rand() % 220) < B.spawnRate; if (TrueFalseB) { - Arr[x][0] = 100000; + Arr[x][0] = B.health; cArr[x][0] = 'b'; } } @@ -131,7 +130,7 @@ cArr2[x+2][y+2] = 'e'; Arr2[x+2][y+2] = Arr[x][y]; //jumps over it cArr2[x][y] = '\0'; Arr2[x][y] = 0; //printf("jump over at [%d][%d] \n",x+1,y+1); - } else if (x == 0 || x == 83 || cArr[x+1][y+1] == 'l' || cArr[x+1][y+1] == 'r' || cArr[x+1][y+1] == 'm') { //if it hits the wall or 'l' or 'r' or 'm'. + } else if (x == 0 || x == 83 || cArr[x+1][y+1] == 'l' || cArr[x+1][y+1] == 'r' || cArr[x+1][y+1] == 'm') { //if it hits either side of the wall or 'l' or 'r' or 'm'. cArr2[x-1][y+1] = 'd'; Arr2[x-1][y+1] = Arr[x][y]; //start moving left & down cArr2[x][y] = '\0'; Arr2[x][y] = 0; //printf("spawn d at x = %d is shifted to e \n",x);