JianWei Lee
/
project_game
Meteor defense project
Diff: Spawn/Spawn.cpp
- Revision:
- 16:ddc4d5669a6e
- Parent:
- 14:064b8d7f348d
- Child:
- 18:d82059ce929b
--- a/Spawn/Spawn.cpp Mon Apr 03 15:52:59 2017 +0000 +++ b/Spawn/Spawn.cpp Fri Apr 07 10:49:57 2017 +0000 @@ -14,7 +14,7 @@ //there is 3 kind of different spawn - a, b and c. if (stopSpawnA == 0) { for ( int x = 0; x < Cols; x++) { - //16/200 chance of spawning for A. + //32/200 chance of spawning for A. //can depends on level bool TrueFalseA = (rand() % 200) < 32; if (TrueFalseA) { @@ -31,7 +31,7 @@ for ( int x = 0; x < Cols; x++) { bool TrueFalseB = (rand() % 200) < 1; if (TrueFalseB) { - Arr2[x][0] = 10000; + Arr2[x][0] = 100000; Arr3[x][0] = 'b'; } bool TrueFalseC = (rand() % 200) < 1; @@ -63,7 +63,7 @@ //printf("moving spawn B \n"); for (int x = 0; x < Cols; x++) { for (int y = 0; y < Rows; y++) { - if (Arr2[x][y] > 8000) { + if (Arr2[x][y] > 10000) { //any number larger than this must be spawn b. Arr1[x][y+1] = Arr2[x][y]; Arr1[x][y] = 0; Arr3[x][y+1] = 'b'; @@ -72,10 +72,10 @@ } } } - void Spawn::updateSpawn(int Arr1[][Rows], int Arr2[][Rows], char Arr3[][Rows],N5110 &lcd) { for ( int x = 0; x < Cols; x++) { for ( int y = 0; y < Rows; y++) { + deleteChar(x, y, Arr1, Arr3); if (Arr3[x][y] == 'a') { lcd.setPixel(x,y); //to update array1 @@ -85,6 +85,8 @@ lcd.setPixel(x,y+1); Arr2[x][y] = Arr1[x][y]; } else if (Arr3[x][y] == 'c') { + Arr3[x-1][y-1] = 'l'; + Arr3[x+1][y-1] = 'r'; lcd.setPixel(x,y); lcd.setPixel(x,y+1); lcd.setPixel(x+1,y); @@ -93,7 +95,6 @@ }else { Arr2[x][y] = 0; } - deleteChar(x, y, Arr1, Arr3); } } }