[Solved] How to execute event repeatedly in Python?
Here’s a simple example using a timer. The screen is filled with a color that changes every 0.4 seconds. import pygame import itertools CUSTOM_TIMER_EVENT = pygame.USEREVENT + 1 my_colors = [“red”, “orange”, “yellow”, “green”, “blue”, “purple”] # create an iterator that will repeat these colours forever color_cycler = itertools.cycle([pygame.color.Color(c) for c in my_colors]) pygame.init() pygame.font.init() … Read more