Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* BAD! */
- float getTimeDelta()
- {
- static unsigned int lastTime = 0;
- unsigned int currentTime = GetTickCount();
- unsigned int timeDelta = currentTime - lastTime;
- lastTime = currentTime;
- return (float)timeDelta * 0.001f;
- }
- /* GOOD ! */
- float getTimeDelta()
- {
- unsigned int timeDelta;
- static unsigned int lastTime = 0;
- unsigned int currentTime = GetTickCount();
- if(currentTime >= lastTime)
- timeDelta = currentTime - lastTime;
- else
- timeDelta = (0xFFFFFFFF - lastTime) + currentTime + 1;
- lastTime = currentTime;
- return (float)timeDelta * 0.001f;
- }
Add Comment
Please, Sign In to add comment