0

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.

Alepale
  • 29
  • 1
  • 2
  • 4

2 Answers2

1

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!
Demandooda
  • 122
  • 1
  • 14
0

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?

Community
  • 1
  • 1
marienbad
  • 1,461
  • 1
  • 9
  • 19