Advertisement
Guest User

Untitled

a guest
Jan 11th, 2020
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. var time = 0.0
  2. var fps = 0
  3. var fpsIt = 0
  4.  
  5. while true:
  6. var frameTime = cpuTime()
  7.  
  8. # Do stuff that takes time
  9.  
  10. let wait = (1.0/ X ) - (cpuTime()-frameTime)
  11. echo wait
  12. if wait > 0.0:
  13. os.sleep(toInt(wait*1000))
  14.  
  15. if fpsIt == 10:
  16. fpsIt = 0
  17. fps = toInt(1.0/((cpuTime()-time)/10.0))
  18. time = cpuTime()
  19. else:
  20. fpsIt += 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement