I am trying to run my program with a timer so that it will stop after 10 seconds but having problems with my iterating through it, so far I've tried using 2 while loops and a while loop within a for loop but have not come right. The program essentially makes shapes fall from top to bottom of the screen but I want it to stop after 10 seconds.
def main():
star = pygame.Rect(75, 0, WIDTH, HEIGHT)
triangle = pygame.Rect(575, 0, WIDTH, HEIGHT)
rectangle = pygame.Rect(175, 0, WIDTH, HEIGHT)
square = pygame.Rect(275, 0, WIDTH, HEIGHT)
hexagon = pygame.Rect(375, 0, WIDTH, HEIGHT)
circle = pygame.Rect(475, 0, WIDTH, HEIGHT)
clock = pygame.time.Clock()
for i in range (10,0,-1):
time.sleep(1)
run = True
while run:
if star.y > HEIGHT:
star.y = -1
elif triangle.y > HEIGHT:
triangle.y = -1
elif rectangle.y > HEIGHT:
rectangle.y = -1
elif square.y > HEIGHT:
square.y = -1
elif hexagon.y > HEIGHT:
hexagon.y = -1
elif circle.y > HEIGHT:
circle.y = -1
clock.tick(FPS)
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
star.y += 2
triangle.y += 2
rectangle.y += 2
square.y += 2
hexagon.y += 2
circle.y += 2
draw_window_one(star, triangle, rectangle, square, hexagon, circle)
pygame.quit()
if __name__ == "__main__":
main()