I'm new to C Sharp, and writing a game w/ the XNA Framework. I've created a project that's a heavily modified version of the "Platformer" XNA starter kit.
I'm seeing (seemingly) random fluctuations with the framerate. Sometimes it'll run at 60 FPS the whole time, sometimes it'll start at 60 FPS then drop to 49-52, and othertimes it'll drop to 49-52 immediately. Using Fraps to display framerate (not recording video to disk).
The unique nature of this game requires that it run at 60 FPS consistently.
So it seems some race condition or random factor is causing a difference between individual runs of the exe. Numerous rebuilds make no difference.
This fluctuation occurs on both my desktop and laptop with exactly the same frequency, so it's not an issue w/ hardware, anti-virus, etc.
I've searched about how to lock framerates in XNA, and my code seems to be doing much of what it needs to do, including an attempt to clamp at 60 FPS (using IsFixedTimeStep, SynchronizeWithVerticalRetrace).
The game is absolutely capable of 60 FPS from beginning to end, I see it all the time. When it's running at 60 FPS it does not tax CPU, RAM or any other resource as far as I can tell.
Anyone else experienced this?
Thanks, - S
The inconsistency you describe means that the problem is either caused by
The most likely cause is another process that is running on both your computers.
Close down all non-essential processes like media players. Windows Media Player and iTunes can both reduce your framerate while they are playing. Fraps should be ok as long as it isn't recording but I would implement your own built in FPS display just to be sure.
Use the windows performance monitor to check if there is a process consuming cpu or memory. Especially look for instances of your game that have failed to shutdown properly and are still running in the background.
Other things you could try to narrow down an environmental cause include:
If the cause is from a code path inside your game that isn't executed on every run you could:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With