Ok, I’ve been testing a game I’ve made, and everything is fine! everything works as it should, except that… there is an animation synchronized with music, this animation runs at 30 fps, so I have a code that makes this one to run at 30 fps in an environment of 60, the problem is that… Pygame sometimes goes over 60 fps, going to 61 and 62 constantly, and although it seems negligible, this ruins my sync, so I was wondering if there was a way to force an exact amount of fps, since even setting the fps to 59 makes it go up.
frame = 0.5
frame_en_pantalla = 1
# More code
frame += 0.5
if frame == int(frame):
frame_en_pantalla = int(frame)
print(clock.get_fps())
clock.tick(60)
Clock.get_fps():
60.975608825683594
61.7283935546875
61.7283935546875
61.7283935546875
61.7283935546875
61.7283935546875
61.7283935546875
61.7283935546875
60.60606002807617
60.60606002807617
60.60606002807617
60.60606002807617
60.60606002807617
62.11180114746094
62.11180114746094
62.11180114746094
I just want to make sure that this does not exceed 60 fps, because if I put the game itself at 30 fps I would have to change some things of the physics, which I do not want, plus I want the character to look fluid itself, as in 30 fps their movements look too slow, but I want to make sure that the game is not too slow, because I want to make sure that the character is smooth.
Andrespro is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.