Time for action – generating fading pieces

  1. In the Game1 class, modify the CheckScoringChain() method by adding the following call inside the foreach loop before the square is set to "Empty":
    gameBoard.AddFadingPiece(
        (int)ScoringSquare.X,
        (int)ScoringSquare.Y,
        gameBoard.GetSquare(
          (int)ScoringSquare.X,
          (int)ScoringSquare.Y));

What just happened?

Adding fading pieces is simply a matter of getting the square (before it is replaced with an empty square) and adding it to the FadingPieces dictionary. We need to use the (int) typecasts because the ScoringSquare variable is a Vector2 value, which stores its X and Y components as floats.

Falling pieces

Falling pieces are added to the game board in two possible locations: From the FillFromAbove() method when ...

Get XNA 4.0 Game Development by Example Beginner's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.