FPS = 30 # frames per second setting
fpsClock = pygame.time.Clock()
while True: # the main game loop
#...
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
pygame.display.update()
fpsClock.tick(FPS)