I am having some trouble with pygame. I am running Mac High Sierra, using Python 3, and using Spyder as my compiler. I am just trying to get a simple animation to run, but the time.delay() function is not working. Whenever I run my code, the pygame window opens, remains grey, and does not fill with white until after the time delays have all run. Then it displays my white screen and the final location of the circle.
How can I get the time.delay function to run properly without just freezing the pygame window?
import pygame, sys
pygame.init()
screen = pygame.display.set_mode([640,480])
screen.fill([255,255,255])
pygame.draw.circle(screen, [255,0,255], [50,50],50, 0)
pygame.display.flip()
for x in range(5,640,5):
pygame.time.wait(20)
pygame.draw.rect(screen, [255,255,255],[x-5,0,100,100],0)
pygame.draw.circle(screen, [255,0,255], [50+x,50],50, 0)
pygame.display.flip()
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()