Advertisement
Guest User

Untitled

a guest
Dec 30th, 2014
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. float fps = 60;
  2. float targetDelta=1/fps; //this is the target time between each update//
  3. float offset=0; //offset tracks how far away this gets from the target//
  4. public void update(float delta){
  5. indexer++; //I assume the frame is timed correctly//
  6. offset+=(delta-targetDelta); //store the difference//
  7. while(offset<-targetDelta){ //and compensate//
  8. offset+=targetDelta;
  9. indexer--;
  10. }
  11. while(offset>targetDelta){
  12. offset-=targetDelta;
  13. indexer++;
  14. }
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement