1
\$\begingroup\$

In the Update function gameTime.elapsedGameTime.TotalSeconds always gives me 0.01666666667 which is the deltaTime value for 60 FPS, no matter if the FPS is 30 it always shows me 0.01666666667 but the Draw function on the other hand shows 0.03333333333 if the FPS is 30.

Is this a bug or is this how it is meant to be? Should I just create a variable called deltaTime and make it equal to gameTime.elapsedGameTime.TotalSeconds in the Draw function? Maybe this is a problem on Macs only

(I'm on a mac and I'm using Xamarin Studio MonoMac to build the project)

\$\endgroup\$
3
  • \$\begingroup\$ Shiro my mac can handle 60FPS the 30 fps thing was just an example \$\endgroup\$
    – user61929
    Jun 19, 2015 at 20:37
  • \$\begingroup\$ Shiro I understand now, Thank you. Just post that as an answer and I'll accept that answer \$\endgroup\$
    – user61929
    Jun 19, 2015 at 20:45
  • \$\begingroup\$ This tutorial explains it in a bit more detail: gamefromscratch.com/post/2015/06/15/… \$\endgroup\$
    – Serapth
    Jun 20, 2015 at 3:17

1 Answer 1

2
\$\begingroup\$

There is no need for the Update() to be called as frequent as Draw(). Your Draw() method is generally called the same or less times than your Update(), because games are usually not CPU intense but rather GPU. So locking on 30FPS is normal (or even 15 or 7,5). However, there are probably problems with your code's efficiency, or your mac hardware is really bad, to not be able to handle 60FPS.

The reason that Update() being called more times than Draw() is acceptable in games, is because even though the visuals doesn't feel smooth, the game still runs at a higher frame rate, so the input you give, gets processed inside your game. So, it feels like the gameplay is the same, but you just don't see as many frames as you would hope to see.

This is why you need to keep in mind that Draw() should not change your game's variables or game's logic. This should only be done in the Update() method.

\$\endgroup\$

You must log in to answer this question.