Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23305

can I get EXACTLY 60 fps in my pygame game?

$
0
0

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.5frame_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.97560882568359461.728393554687561.728393554687561.728393554687561.728393554687561.728393554687561.728393554687561.728393554687560.6060600280761760.6060600280761760.6060600280761760.6060600280761760.6060600280761762.1118011474609462.1118011474609462.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.


Viewing all articles
Browse latest Browse all 23305

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>