Fork me on GitHub
Nation Pigeon

Frame rate independent movement in PyGame

19th August 09 | Tags: , , ,

To make sure that your game runs the same on all computers that can handle it. You will need to make sure that your actions are independent from the frame rate. To do this in python you can put this code above the game loop

framerate = 60 #frames per second
clock = pygame.time.Clock()

and then at the end of your game loop put

timepassed = clock.tick(framerate)

This should help with makeing the game more playable ^_^
Hope this helps.

Categories: Programming

Leave a Reply

Copyright © 2007 ∞ Nation Pigeon - Designed by Peter Mayanrd
Theme Based on Black-Green - Fork it on GitHub