Pygame Help: Game Text Constantly Stuck On Screen (timer Not Working)
Solution 1:
The text appears after two seconds because after blitting the text to the screen, you pause your game for two seconds before updating the screen:
bg.blit(TextSurf, TextRect) <<< MAKING SURE THE TEXT OVERLAPS THE BACKROUND IMAGE
time.sleep(2) <<<<< TWO SECOND TIMER
game_loop() <<<< RUN THE MAIN GAME LOOP
So instead of blocking your entire game with time.sleep(2)
, you have to keep your main loop running.
You could use an event to trigger a state change of your game. To get an idea of how custom events work, take a look here and here.
Then the text never disappears because you blit the text to the Surface
you use as your background surface, and you continue to blit this now altered Surface
to the screen:
bg.blit(TextSurf, TextRect) <<< MAKING SURE THE TEXT OVERLAPS THE BACKROUND IMAGE
So instead of drawing the text to the background Surface
, blit it to the screen Surface
directly.
There are some other issues with your code but that's out of scope of this answer, but you should get the idea of how to solve your main issues.
Post a Comment for "Pygame Help: Game Text Constantly Stuck On Screen (timer Not Working)"