Time for action – the TileMap class – part 3
Add the
Draw()
method to the TileMap class:#region Drawing static public void Draw(SpriteBatch spriteBatch) { int startX = GetCellByPixelX((int)Camera.Position.X); int endX = GetCellByPixelX((int)Camera.Position.X + Camera.ViewPortWidth); int startY = GetCellByPixelY((int)Camera.Position.Y); int endY = GetCellByPixelY((int)Camera.Position.Y + Camera.ViewPortHeight); for (int x = startX; x <= endX; x++) for (int y = startY; y <= endY; y++) { for (int z = 0; z < MapLayers; z++) { if ((x >= 0) && (y >= 0) && (x < MapWidth) && (y < MapHeight)) { spriteBatch.Draw( tileSheet, CellScreenRectangle(x,y), TileSourceRectangle(mapCells[x,y].LayerTiles[z]), ...