I've changed the frame rate (FPS)

Default is 60 FPS in Monogame..

While I've been developing my game for quite some time now I've noticed that the FPS was constantly showing around 60 FPS, I never focused on this until today.
Apparently Monogame defaults the FPS to 60 but there are ways to happily change this!

One way is to shut it off completely so that you can handle the FPS yourself, here's how to do that.

In your Game constructor do the following..

public Game1()
{
            graphics = new GraphicsDeviceManager(this);
         
            // Shut this off, otherwise the GPU will lock the FPS
            // to you monitor's frame rate.
            graphics.SynchronizeWithVerticalRetrace = false;
            graphics.ApplyChanges();

            // Then tell Monogame not to use its own FPS handling
            this.IsFixedTimeStep = false;
}

Now it will be up to you as a developer to make the game flow steady.
The other (better) way, the way I'll do it is to make the following changes.

Once again in your Game constructor..

public Game1()
{
            graphics = new GraphicsDeviceManager(this);

            // Shut this off, otherwise the FPS will be locked to
            // you monitors frame rate.
            graphics.SynchronizeWithVerticalRetrace = false;
            graphics.ApplyChanges();

            // Now instead of shutting it off completely in Monogame
            // change the default 60 FPS to for an example 100 FPS like this.
            this.TargetElapsedTime = TimeSpan.FromSeconds(1.0f / 100.0f);
}

Now my FPS will be around 100 instead of the default 60 and I'll never let my game drop under 60 FPS, because then I'll have to make things more effective in my game to keep it above 60.

See you!

Kommentarer