Time for action – drawing the tile map
Add the
Draw()
method to theTileMap
module:#Region "Drawing" Public Sub Draw(spriteBatch As SpriteBatch) Dim startX As Integer = GetSquareByPixelX(CInt(Int(Camera.Position.X))) Dim endX As Integer = GetSquareByPixelX(CInt(Int(Camera.Position.X)) + Camera.ViewPortWidth) Dim startY As Integer = GetSquareByPixelY(CInt(Int(Camera.Position.Y))) Dim endY As Integer = GetSquareByPixelY(CInt(Int(Camera.Position.Y)) + Camera.ViewPortHeight) For x As Integer = startX to endX For y As Integer = startY to endY If ((x >= 0) And (y >= 0) And (x < MapWidth) And (y < MapHeight)) Then spriteBatch.Draw( _texture, SquareScreenRectangle(x, y), _tiles(GetTileAtSquare(x,y)), Color.White) End If Next Next End Sub #End Region
In the
LoadContent()
method of theGame1
class, initialize theTileMap
module (outside of the temporary code block, after the...