Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var time = 0.0
- var fps = 0
- var fpsIt = 0
- while true:
- var frameTime = cpuTime()
- # Do stuff that takes time
- let wait = (1.0/ X ) - (cpuTime()-frameTime)
- echo wait
- if wait > 0.0:
- os.sleep(toInt(wait*1000))
- if fpsIt == 10:
- fpsIt = 0
- fps = toInt(1.0/((cpuTime()-time)/10.0))
- time = cpuTime()
- else:
- fpsIt += 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement