I have this function for tetris game in c++ that suppose to check the if the col
ID: 3629595 • Letter: I
Question
I have this function for tetris game in c++ that suppose to check the if the column is fulled, and then delete the fulled row and move everything above one column down.however it is not working correctly, it only clear the first tilt of the full column and problem freeze.
void Game::CheckLine(){
for (int r=0; r<ROW; r++) {
bool rowFull = true;
for (int c=0; c<COLUMN; c++) {
if(!grid[c][r].filled){ //check all col at same row are filled
rowFull = false;
break;
}
}
if(rowFull){ //if all col at same row are filled
lines++;
for (int c=0; c<COLUMN; c++) {
grid[c][r].filled = false;
reDraw();
for (int x=r; x >= 0; x--){
if(grid[c][x].filled){
grid[c][x].filled = false;
grid[c][x+1].filled = true;
grid[c][x+1].red = grid[c][x].red;
grid[c][x+1].green = grid[c][x].green;
grid[c][x+1].blue = grid[c][x].blue;
reDraw();
}
}
}
}
}
}
Explanation / Answer
Try this: void Game::CheckLine(){ for (int r=0; rRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.