Fix pew.tick() to not accumulate error over time

This commit is contained in:
Radomir Dopieralski 2019-03-01 15:54:16 +01:00
parent 3826ca4194
commit 8e50aeb06f

View File

@ -63,8 +63,12 @@ def show(pix):
def tick(delay): def tick(delay):
global _tick global _tick
now = time.monotonic()
_tick += delay _tick += delay
time.sleep(max(0, _tick - time.monotonic())) if _tick < now:
_tick = now
else:
time.sleep(_tick - now)
class GameOver(Exception): class GameOver(Exception):