static int check_lines() { int i,j; int total = 0; int lines = 0; for(i = 0; i < 4; i++) { if(row+i < 20) { for(j = 0; j < 14; j++) { total += grid[row+i][j]; } } if(total == 14) { lines++; copy_down(row+i, grid); trigger_event("LineCleared", (void*)row+i); } total = 0; } trigger_event("DoneClearing", (void*)row+i); return lines; }
int map::clear_lines(int top, int bottom) { int cleared_lines = 0; for (int row = top; row <= bottom; ++row) { if (!is_clearing_line(row)) continue; ++cleared_lines; // 下移一行 if (copy_down(row)) continue; // 最上一行清空 for (int i = 0; i < width_; i++) get_node(i, 0).reset(); } return cleared_lines; }