Time for action – generating fading pieces
In the
Game1
class, modify theCheckScoringChain()
method by adding the following call inside thefor each
loop, before the square is set toEmpty
:_gameBoard.AddFadingPiece( CInt(thisPipe.X), CInt(thisPipe.Y), _gameBoard.GetSquare( CInt(thisPipe.X), CInt(thisPipe.Y)))
What just happened?
Adding fading pieces is simply a matter of getting the type of piece currently occupying the square that we wish to remove (before it is replaced with an empty square) and adding it to the FadingPieces
dictionary. We need to use the CInt
typecasts because the thisPipe
variable is a Vector2
value, which stores its X
and Y
components as Singles
.
Falling pieces
Falling pieces are added to the game board in two possible locations: from the FillFromAbove()
method when a piece is being moved from one location on the board to another, and in the GenerateNewPieces()
method when a new piece falls in from the top of the game board.