python - how to add a rectangle after a certain period in pygame -


i wondering how add rectangle shape after user has gained 10 points.

i have function called blocks() draws rectangle. code snippet have written

#bunch of code main_gameloop()   while running:       #bunch of code         if score >= 10:           blocks()           pygame.display.update()        p.display.update()        clock.tick(fps) main_gameloop() 

but happens when user has gained 10p rectangle flashes on , off doesnt display solid

when user has gained 10p rectangle flashes on , off

it doesnt display solid

i presuming logic stepped through each time clock.tick runs. flickering caused rectangle re-drawing each time "blocks()" called per timer.

you prevent rectangle flickering checking see if rectangle has been drawn before re-drawing it.

some pseudo code provided below

    bool shown = false      blocks()         …        shown=true      if score >= 10         if ! shown            blocks()        …        clock.tick(fps) 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -