Skip to content

Instantly share code, notes, and snippets.

@shawn42
Created March 15, 2009 19:59
Show Gist options
  • Save shawn42/79525 to your computer and use it in GitHub Desktop.
Save shawn42/79525 to your computer and use it in GitHub Desktop.
class Clock
def tick()
passed = Clock.runtime() - @last_tick # how long since the last tick?
if @target_frametime
wait = @target_frametime - passed
if wait > 0
return Clock.wait(@target_frametime - passed) + passed
else
return passed
end
# return Clock.delay(@target_frametime - passed, 1) + passed
end
return passed
ensure
@last_tick = Clock.runtime()
@ticks += 1
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment