Reputation: 29
I'm creating a game and at the "start" screen I want it to pop up a picture after 45 seconds of not starting the game saying "Are you not going to play?"
However, I am completely lost at what to do, so if anyone have any clue on how to help that would be really appreciated.
Upvotes: 0
Views: 526
Reputation: 1453
You can set a timer and an event on the event queue. This answer shows how to do that. How can I detect if the user has double-clicked in pygame?
Upvotes: 0
Reputation: 122
You probably have a timer for your game, like this:
pygame.time.Clock.tick(fps)
Each time your main loop runs, it ticks your fps, so your game could run smoothly.
Now, just add a variable, called, say, tick_counter
Now, in your code, do something like this:
fps = 25
tick_counter = 0
while RUNNING:
#Do stuff, check for if close window, etc
pygame.time.Clock.tick(fps)
tick_counter += 1
if tick_counter >= 1125: #45 seconds if you are doing 25 fps. If your fps is different, just calculate it: 45 seconds = 45*fps
#Pop up the picture!
Upvotes: 1