JianWei Lee
/
project_game
Meteor defense project
Diff: Spawn/Spawn.cpp
- Revision:
- 5:c74bbdda06f4
- Parent:
- 3:6b50fe9d3848
- Child:
- 6:a554424e4517
--- a/Spawn/Spawn.cpp Wed Mar 22 15:19:20 2017 +0000 +++ b/Spawn/Spawn.cpp Wed Mar 22 17:15:38 2017 +0000 @@ -16,7 +16,8 @@ stopSpawn = 1; for ( int x = 0; x < Cols; x++) { //30% chance of spawning - bool TrueFalse = (rand() % 100) < 30; + //can depends on level + bool TrueFalse = (rand() % 100) < 20; if (TrueFalse) { //spawning from the top of the screen spawnArray1[x][0] = 1; @@ -36,9 +37,9 @@ for ( int x = 0; x < Cols; x++) { spawnArray2[x][0] = 0; for ( int y = 0; y < Rows; y++) { - if (spawnArray1[x][y] == 1) { + if (spawnArray1[x][y] > 0) { //move it down a row - spawnArray2[x][y+1] = 1; + spawnArray2[x][y+1] = spawnArray1[x][y]; } else { spawnArray2[x][y+1] = 0; } @@ -50,10 +51,10 @@ void Spawn::updateSpawn(N5110 &lcd) { for ( int x = 0; x < Cols; x++) { for ( int y = 0; y < Rows; y++) { - if (spawnArray2[x][y] == 1) { + if (spawnArray2[x][y] > 0) { lcd.setPixel(x,y); //to update array1 - spawnArray1[x][y] = 1; + spawnArray1[x][y] = spawnArray2[x][y]; } else { spawnArray1[x][y] = 0; }