Reputation: 183
I was wondering if there was any sort of code to make something disappear from the screen after a set time? Something like an intro to your game?
Upvotes: 0
Views: 1976
Reputation: 16711
You used the timer tag so use a threading.Timer
object to call a function after some time:
class Menu:
def __init__(self):
self.active = True
# start a timer for the menu
Timer(3, self.reset).start()
def update(self, scr):
if self.active:
surf = pygame.Surface((100, 100))
surf.fill((255, 255, 255))
scr.blit(surf, (270, 190))
def reset(self):
self.active = False
menu = Menu()
while True:
pygame.display.update()
queue = pygame.event.get()
scr.fill((0, 0, 0))
for event in queue:
if event.type == QUIT:
pygame.quit(); sys.exit()
menu.update(scr)
Upvotes: 0
Reputation: 33670
You should use pygame.time.Clock
to track time as it passes.
Upvotes: 1