parent
79e400d1ea
commit
419dc147c0
|
@ -0,0 +1,18 @@
|
||||||
|
from time import time
|
||||||
|
|
||||||
|
|
||||||
|
class Timer:
|
||||||
|
def __init__(self) -> None:
|
||||||
|
self.running = False
|
||||||
|
self.old = 0
|
||||||
|
|
||||||
|
def control_fps(self, fps: int) -> int:
|
||||||
|
if not self.running:
|
||||||
|
self.old = time()
|
||||||
|
return
|
||||||
|
|
||||||
|
delay_between_frames = 1 / fps
|
||||||
|
now = time()
|
||||||
|
while now - self.old < delay_between_frames:
|
||||||
|
now = time()
|
||||||
|
self.old = now
|
Loading…
Reference in New Issue