1
votes

I already read the post over here but it's different than my question.

I'm making a game, the game's main ingredient is a countdown timer (no character moving, no map only a timer) - and I'm looking for a way that I could update the screen globally every millisecond to the current time.

My question is, should I give up on having it update every millisecond or is there any way to take care of it this? Using time or just maybe pygame.Clock - if there's another way of doing a countdown timer (while in game, so it won't influence the FPS, please let me know).

1
Pygame's clock will let you update the text every millisecond, but your screen is only going to refresh at its refresh rate, so you won't see every update. Are you ok with that? - derricw
you could use set_timer() with USEREVENT, to avoid linking your timer step with fps. See the code example there - jfs
Linking this question, since it has correct answers. - skrx

1 Answers

0
votes

Yes this is possible using the pygame.time.Clock. You just use the tick method with the fps that you want. But keep in mind you are only going to see updates as fast as your screen refreshes.

clock = pygame.time.Clock()
while True:
    clock.tick(1000)  # waits until the next ms
    #clear your frame here
    #update and draw your text here
    #flip your display window here