# In the game loop, apply dt before the loop starts, or after it finishes?

Say I have a Game class with an update loop that receives a time increment dt by parameter. I was wondering if it's better or customary to apply this dt before the loop starts or after the loop finishes.

class Game
{
void Update(float dt);
float m_time;
}


dt is the delta time from last update loop.

m_time is the total accumulated time since the game started running.

Option 1:

void Game::Update(float dt)
{
m_time += dt;
/*
do stuff
*/
}

• Pros: I think it's more clear.
• Cons: No update loop is processed at m_time = 0. The very first update loop already has m_time = dt.

Option 2:

void Game::Update(float dt)
{
/*
do stuff
*/
m_time += dt;
}

• Pros: The update loop starts at m_time = 0.
• Cons: I find it a bit weird that the time is updated after all the processing has finished.

Any advise on which option is better or preferred over the other?

• What is dt and what is m_time? May 22 '15 at 8:48
• Edit that into your question so I can take back the down vote. It's a good question and I feel bad for giving it -1. May 22 '15 at 9:15
• I've improved variables descriptions in my original post. May 22 '15 at 12:27

• Yeah, dt is the time delta between frames, and m_time, in this simple example I set, is obviously the accumulated time since the game started. From your answer, I imply that the game will never have an update loop with m_time = 0, which is what I find a bit weird. Can't this cause strange effects? For example, animations that don't start playing from the beginning. May 22 '15 at 8:54