Time for action – drawing the screen – the play screen
In the
GameBoard
class, add theDraw()
method to allow the game board to draw itself:Public Sub Draw( spriteBatch As SpriteBatch, DisplayOrigin As Vector2) Dim x As Integer, y As Integer For x = 0 To GameBoardWidth For y = 0 To GameBoardHeight Dim pixelX As Integer = CInt(DisplayOrigin.X + (x * GamePiece.PieceWidth)) Dim pixelY As Integer = CInt(DisplayOrigin.Y + (y * GamePiece.PieceHeight)) spriteBatch.Draw( playingPieces,New Rectangle( pixelX,pixelY,GamePiece.PieceWidth,GamePiece.PieceHeight),EmptyPiece,Color.White) spriteBatch.Draw( playingPieces,New Rectangle( pixelX,pixelY,GamePiece.PieceWidth,GamePiece.PieceHeight),GetSourceRect(x, y),Color.White) Next Next End Sub
Update the
Draw()
method of theGame1
class to add the code to call theDraw()
method ofGameBoard
. Place this code after the code that draws the title screen:If gameState = GameStates.Playing...