Mark Horizontal Rows
- In the TETRIS game, when a horizontal row is filled up with
tetrominoes so that there is no gap, this row can be removed.
- However, this is a complex procedure, so let us divide it into
several smaller sub-tasks. This "Divide
and Conquer" strategy will be very helpful for you to design a complicated
algorithm.
- In our case, we shall design several functions which, when combined
together, will clear a horizontal row when there is no gap.
- In this exercise, let us first design a function
check_horizontal(int i), which will check whether all elements in the row
occupied[i] are true.
-
When you invoke update_occupy(),
it should automatically
invoke check_horizontal(i) for each row.
If it returns true, mark the row(s) with a string "->".
- Because the function
check_horizontal()
will only be
invoked internally from update_occupy()
, you may design it
as a private member function in the class CTetromino
.