0
\$\begingroup\$

I have looked up ways to calculate DeltaTime in the past, but the 'solutions' seem to have my program be slightly jittery or not move things correctly. As far as I know, you would calculate it by finding the difference in time between the current and previous frame (Is this correct?). I have seen solutions find out DeltaTime with a fixed frame rate, but that is not what I am looking for.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ You have two options: SDL_GetTicks or SDL_GetPerformanceCounter & SDL_GetPerformanceFrequency, both mentioned at How to measure time interval (different languages). The latter can be more precise, and more precise can mean less stable frame steps. So, by "fixed frame rate", do you mean the approach from the infamous Fix Your Timestep! or are you doing something else? And by jitter do you mean some frame the game advances more, or something else? \$\endgroup\$ Commented Aug 29 at 21:20
  • 1
    \$\begingroup\$ Can you show us the code you wrote that misbehaved? Without this, we're left guessing at what the source of your error might have been. Try editing your question to include a Minimal Complete Verifiable Example: all the code we would need to reproduce the jittery or incorrect movement you're seeing. This will help you get correct, helpful answers, faster. \$\endgroup\$ Commented Aug 29 at 21:29

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.