(This is the last thing I have to get working before the code for my falling block game is done.)
This code is supposed to check if a row is full. If it should remove that row.
Simultaneously it should be checking if a row is empty. If the row is empty it moves everything above it down 1 spot.
Note::I tested rowFull() and remove(). Both work properly. (rowFull returns bool if the row specified is full of 2's. Remove changes the row to all 0's.)
"1"s are the border. Or where I will draw the border when I write the GUI.
void gameMap::remap() { //check for empty rows and fall if required. int y = 19, sum = 0; for (int j = y; j>=0 ; j--) { sum = 0; if (rowFull(j)){ remove(j); } for (int i = 1; i < 11; i++) { sum += map[j]; } if (sum == 0) { for (int i = 1; i < 11; i++) { for (int j = y; j > 0; j--) { map[j] = map[j-1]; } } } }
Input gameMap:
1 0 0 0 0 0 0 0 0 0 0 11 0 0 0 0 0 0 0 0 0 0 11 0 0 0 0 0 0 0 0 0 0 11 0 0 0 0 0 0 0 0 0 0 11 0 0 0 0 0 0 0 0 0 0 11 2 2 2 2 2 2 2 2 2 2 11 2 2 2 2 2 2 2 2 2 0 11 0 0 0 0 0 0 0 0 0 0 11 0 0 0 0 0 0 0 0 0 0 11 0 0 0 0 0 0 0 0 0 0 11 0 0 0 0 0 0 0 0 0 0 11 0 0 0 0 0 0 0 0 0 0 11 0 0 0 0 0 0 0 0 0 0 11 0 0 0 0 0 0 0 0 0 0 11 0 0 0 0 0 0 0 0 0 0 11 0 0 0 0 0 0 0 0 0 0 11 0 0 0 0 0 0 0 0 0 0 11 0 0 0 0 0 0 0 0 0 0 11 0 0 0 0 0 0 0 0 0 0 11 0 0 0 0 0 0 0 0 0 0 11 1 1 1 1 1 1 1 1 1 1 1
Output I'm getting:
1 0 0 0 0 0 0 0 0 0 0 11 0 0 0 0 0 0 0 0 0 0 11 0 0 0 0 0 0 0 0 0 0 11 0 0 0 0 0 0 0 0 0 0 11 0 0 0 0 0 0 0 0 0 0 11 0 0 0 0 0 0 0 0 0 0 11 0 0 0 0 0 0 0 0 0 0 11 0 0 0 0 0 0 0 0 0 0 11 0 0 0 0 0 0 0 0 0 0 11 0 0 0 0 0 0 0 0 0 0 11 0 0 0 0 0 0 0 0 0 0 11 0 0 0 0 0 0 0 0 0 0 11 0 0 0 0 0 0 0 0 0 0 11 0 0 0 0 0 0 0 0 0 0 11 0 0 0 0 0 0 0 0 0 0 11 0 0 0 0 0 0 0 0 0 0 11 0 0 0 0 0 0 0 0 0 0 11 0 0 0 0 0 0 0 0 0 0 11 0 0 0 0 0 0 0 0 0 0 11 0 0 0 0 0 0 0 0 0 0 11 1 1 1 1 1 1 1 1 1 1 1
Assuming that for some reason my program continues to drop rows ontop of the remaped row. so when the 2 2 2 2 2 2 row moves down once, a 0 0 0 0 0 0 row moves ontop of it.
Can't see where its happening though. (Just finished writing the code, and don't want to wait til tomorrow to look at it)
So was hoping that someone else could let me know what they see.