TiledLib.Map.DrawAsMap C# (CSharp) Method

DrawAsMap() public method

Draws all layers of the map
public DrawAsMap ( SpriteBatch spriteBatch, int scale ) : void
spriteBatch Microsoft.Xna.Framework.Graphics.SpriteBatch The SpriteBatch to use to render the map.
scale int
return void
        public void DrawAsMap(SpriteBatch spriteBatch, int scale)
        {
            foreach (var l in Layers)
            {
                if (!l.Visible)
                    continue;

                TileLayer tileLayer = l as TileLayer;
                if (tileLayer != null)
                {

                    for (int y = 0; y < Height; y++)
                    {
                        for (int x = 0;x<Width ; x++)
                        {
                            if (x >= 0 && x < tileLayer.Width && y >= 0 && y < tileLayer.Height)
                            {
                                Tile tile = tileLayer.Tiles[x, y];

                                if (tile != null && tile.Texture != null)
                                {
                                    spriteBatch.Draw(tile.Texture, new Rectangle(x * (int)(TileWidth / scale), y * (int)(TileHeight / scale), (int)(TileWidth / scale), (int)(TileHeight / scale)), tile.Source, Color.White);
                                }
                            }

                        }
                    }
                }
            }
        }