Created
June 25, 2012 15:37
-
-
Save ralphbean/2989313 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| _last_called = time.time() | |
| def animate(): | |
| global r | |
| global _last_called | |
| now = time.time() | |
| if now - _last_called > 2: # 2 is in seconds | |
| # Remember when I was called last | |
| _last_called = now | |
| # Determine a new random position | |
| x = random.randint(0, width) | |
| y = random.randint(0, height) | |
| # pygame.Rect needs 'left', 'top', 'width', 'height' | |
| # The 100, and the 50 are borrowed from the Surface above | |
| r = pygame.Rect(x, y, 100, 50) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment