Skip to content

Learning Python: Day 49

Controlling the frame rate

  • framerate – the speed at which a game runs
  • with Pygame, can make a clock to ensure clock ticks once on each pass through the main loop
  • if the loop processes faster than the defined rate, Pygame will calculate how much time to pause to keep the rate consistent
  • define the clock in the __init__() method:
  • added self.clock = pygame.time.Clock()
  • added self.clock.tick(60) so the game runs at 60 fps
Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *