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)
Asked By: Vojtěch Šokala

||

Answers:

fpstimer might help
It can maintain certain a FPS in runtime
here is its PYPI link:
https://pypi.org/project/fpstimer

Answered By: faked grid
Categories: questions Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.