@ -7,13 +7,17 @@ def delay(secs: float) -> generator:
yield None
def fps(dt: float):
def fps(dt: float) -> generator:
until = time.monotonic() + dt
while True:
remain = until - time.monotonic()
until += dt
if remain > 0:
time.sleep(remain)
if remain < -dt:
# Catch up a bit
until += -remain / 3