Pygame time module?

A forum for general discussion of the Python programming language.

Pygame time module?

Postby BlueBeachMonster » Sun Apr 06, 2014 2:18 pm

I need a pygame time module that won't freeze the entire game for the specified time.
Any suggestions?
(Instead of things like: time.sleep(n) or pygame.time.wait(n))
Posts: 5
Joined: Fri Apr 04, 2014 8:33 pm

Re: Pygame time module?

Postby Mekire » Sun Apr 06, 2014 2:43 pm

This seems identical to your other post. Please do not create duplicate posts.

In pygame, for controlling the framerate of the whole program, you create a clock:
Code: Select all
clock = pygame.time.Clock()
Then every frame you call that clocks tick method to limit the game to a specific framerate:
Code: Select all

For timing individual events you will want to use:
Code: Select all

New Users, Read This
  • Use code tags when posting code.
  • Include any errors with your post (in code tags).
  • Describe your problem; not your chosen solution.
  • Make examples the minimum length to demonstrate your issue.
User avatar
Posts: 1711
Joined: Thu Feb 07, 2013 11:33 pm
Location: Tucson, Arizona

Return to General Discussions

Who is online

Users browsing this forum: Bing [Bot] and 5 guests