Time for action – create the GameBoard.cs class
As you did to create the GamePiece class, right-click on Flood Control in Solution Explorer and select Add | Class... Name the new class file GameBoard.cs.
Add the
using
directive for the XNA framework at the top of the file:using Microsoft.Xna.Framework;
Add the following declarations to the GameBoard class:
Random rand = new Random(); public const int GameBoardWidth = 8; public const int GameBoardHeight = 10; private GamePiece[,] boardSquares = new GamePiece[GameBoardWidth, GameBoardHeight]; private List<Vector2> WaterTracker = new List<Vector2>();
What just happened?
We used the Random class in SquareChase to generate random numbers. Since we will need to randomly generate pieces to add to the game board, we need an instance of Random in the GameBoard class.
The two constants and the boardSquares
array provide the storage mechanism for the GamePiece objects that make up the 8 by 10 piece board.
Finally, a List of...