# Frame-rate drops when drawing 2D map tiles

Update: I figured out it has nothing to do with the camera but instead framerate drops when drawing my map tiles onto the screen. Here’s a link to a video showcasing the bug in action (For further reference): https://streamable.com/m4zuf3

Any and all guidance is appreciated, thanks.

Here's the draw functions:

    protected override void Draw(GameTime gameTime)
{
m_mainLevel.Draw(spriteBatch);
}

        public void Draw(SpriteBatch sb)
{
//Draw Background
for (var i = 0; i < BackgroundTiles.Length; i++)
{
int id = BackgroundTiles[i].m_id;

int column = id % TilesetTilesWide;
int row = (int)Math.Floor((double)id / (double)TilesetTilesWide);

int width = Map.TileWidth * 2;
int height = Map.TileWidth * 2;

float x = (i % Map.Width) * width;
float y = (float)Math.Floor(i / (double)Map.Width) * height;

Rectangle tilesetRec = new Rectangle(TileWidth * column, TileHeight * row, TileWidth, TileHeight);
Rectangle dest = new Rectangle((int)x, (int)y, width, height);
sb.Draw(Tileset, dest, tilesetRec, Color.White);
}
}


Is the problem that I'm drawing too many tiles per frame? the map size is 250 x 250 tiles, with each tile being 16x16px.

• Sounds like judder. Don't forget to include the relevant code in your question so we can help you debug it. – DMGregory Jun 23 at 3:28
• For course, I figured out that it's not the camera but instead has to do with framerate drops. – TheCo Jun 23 at 4:05

if(bounds.Intersects(dest)) sb.Draw(Tileset, dest, tilesetRec, Color.White);