Time for action – the TileMap module – part 3
Add the
Draw()
method to theTileMap
module:#Region "Drawing" Public Sub Draw(spriteBatch As SpriteBatch) Dim startX As Integer startX = GetCellByPixelX(CInt(Int(Camera.Position.X))) Dim endX As Integer endX = GetCellByPixelX(CInt(Int(Camera.Position.X)) +Camera.ViewPortWidth) Dim startY As Integer startY = GetCellByPixelY(CInt(Int(Camera.Position.Y))) Dim endY As Integer endY = GetCellByPixelY(CInt(Int(Camera.Position.Y)) +Camera.ViewPortHeight) For x As Integer = startX To endX For y As Integer = startY To endY For z As Integer = 0 To MapLayers - 1 If ((x >= 0) And (y >= 0) And(x < MapWidth) And (y < MapHeight)) Then spriteBatch.Draw( tileSheet, CellScreenRectangle(x,y), TileSourceRectangle(mapCells(x,y).LayerTiles(z)), Color.White, 0.0, Vector2.Zero, SpriteEffects...