- XNA 4.0 Game Development by Example Beginner's Guide(Visual Basic Edition)
- Kurt Jaegers
- 153字
- 2021-08-20 15:50:39
The GameBoard class
Now that we have a way to represent pieces in memory, the next logical step is to create a way to represent an entire board of playing pieces.
The game board is a two-dimensional array of GamePiece
objects, and we can build in some additional functionality to allow our code to interact with pieces on the game board by their X
and Y
coordinates.
- Store a
GamePiece
object for each square on the game board - Provide methods for code using the
GameBoard
to update individual pieces, by passing calls through to the underlyingGamePiece
instances - Randomly assign a piece type to a
GamePiece
- Set and clear the "Filled with water" flags on individual
GamePieces
- Determine which pipes should be filled with water, based on their position and orientation, and mark them as filled
- Return lists of potentially scoring water chains to code using the
GameBoard