Guest User

Untitled

a guest
Jul 17th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. /* BAD! */
  2. float getTimeDelta()
  3. {
  4. static unsigned int lastTime = 0;
  5. unsigned int currentTime = GetTickCount();
  6. unsigned int timeDelta = currentTime - lastTime;
  7. lastTime = currentTime;
  8. return (float)timeDelta * 0.001f;
  9. }
  10.  
  11. /* GOOD ! */
  12. float getTimeDelta()
  13. {
  14. unsigned int timeDelta;
  15. static unsigned int lastTime = 0;
  16. unsigned int currentTime = GetTickCount();
  17. if(currentTime >= lastTime)
  18. timeDelta = currentTime - lastTime;
  19. else
  20. timeDelta = (0xFFFFFFFF - lastTime) + currentTime + 1;
  21.  
  22. lastTime = currentTime;
  23. return (float)timeDelta * 0.001f;
  24. }
Add Comment
Please, Sign In to add comment