Update: I figured out it has nothing to do with the camera but instead framerate drops when drawing my map tiles onto the screen.

Framerate drops

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)
        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.

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

1 Answer 1


I solved it.

if(bounds.Intersects(dest)) sb.Draw(Tileset, dest, tilesetRec, Color.White);
  • 3
    \$\begingroup\$ Hi, can you please elaborate slightly on how this line of code solves the problem? As far as I can tell, it checks the coordinates of the tile it is about to draw and only draws it if it is onscreen, but I am unsure. \$\endgroup\$ Jun 23, 2020 at 9:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .