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
1 changed files with 5 additions and 1 deletions

View File

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