End Function
Private Sub ClearMarkedForDeletion()
Dim row As Integer
Dim column As Integer
For column = matrix.GetLength(1) – 1 To 0 Step -1
' If column is completely empty, then move everthing
' down one.
For row = 0 To matrix.GetLength(0) – 1
If Not matrix(row, column) Is Nothing Then
matrix(row, column).MarkedForDeletion = False
End If
Next
Next
End Sub
''' <summary>
''' Find out how many blocks will be eliminated.
''' </summary>
''' <returns></returns>
''' <remarks></remarks>
Private Function CalculateScore() As Integer
Dim row As Integer
Dim column As Integer
Dim total As Integer = 0
For column = matrix.GetLength(1) – 1 To 0 Step -1
' If column is completely empty, then move everthing
' down one.
For row = 0 To matrix.GetLength(0) – 1
If Not matrix(row, column) Is Nothing Then
If matrix(row, column).MarkedForDeletion Then
total += 1
End If
End If
Next
Next
Return total
End Function
''' <summary>
''' After the blocks are removed from the columns, there may be
''' columns that are empty. Move columns from right to left to
''' fill in the empty columns.
''' </summary>
''' <remarks></remarks>
Public Sub CollapseColumns()
Dim row As Integer
Dim column As Integer
For column = matrix.GetLength(1) – 1 To 0 Step -1
' If column is completely empty, then all the columns
' over one.
Dim noBlocks As Boolean = True
For row = 0 To matrix.GetLength(0) – 1