Better way of printing ascii art at given framerate
Question:
I am trying to optimize printing ascii art at given framerate. Now i am using time.sleep() but this is inconsistent because it doesnt add time when the frames are opening. I am asking is there a library which can handle this for me ?
This is my curent code:
def play_ascii():
maxcount = len(os.listdir('temp/ascii'))
count = 1
interval = input("Sleep between frames (recommended value: 0.03)")
winsound.PlaySound("temp/audio.wav",winsound.SND_ASYNC or winsound.SND_ALIAS)
while count != maxcount:
print(open("temp/ascii/frame{:05d}.txt".format(count)).read())
time.sleep(float(interval))
count+=1
winsound.PlaySound(None,winsound.SND_ASYNC)
Answers:
fpstimer might help
It can maintain certain a FPS in runtime
here is its PYPI link:
https://pypi.org/project/fpstimer
I am trying to optimize printing ascii art at given framerate. Now i am using time.sleep() but this is inconsistent because it doesnt add time when the frames are opening. I am asking is there a library which can handle this for me ?
This is my curent code:
def play_ascii():
maxcount = len(os.listdir('temp/ascii'))
count = 1
interval = input("Sleep between frames (recommended value: 0.03)")
winsound.PlaySound("temp/audio.wav",winsound.SND_ASYNC or winsound.SND_ALIAS)
while count != maxcount:
print(open("temp/ascii/frame{:05d}.txt".format(count)).read())
time.sleep(float(interval))
count+=1
winsound.PlaySound(None,winsound.SND_ASYNC)
fpstimer might help
It can maintain certain a FPS in runtime
here is its PYPI link:
https://pypi.org/project/fpstimer