Welcome to the CSC Q&A.
Get help and give help!
Write great code!
It is our choices... that show what we truly are, far more than our abilities.

Categories

+2 votes

For my final project I am trying to display the score the whole time you are playing, but I am having a problem. The score updates, but it flashes. I think it is because of where my .undraw() is but not sure. Here is the function:

while keepPlaying:
    scoreText = Text(Point(700, 50), f"Score: {score}")
    scoreText.setTextColor('purple')
    scoreText.setSize(15)
    scoreText.draw(window)
    (some code for the game between here)
     scoreText.undraw()
asked in CSC201 Spring 2021 by (1.3k points)

1 Answer

+2 votes

I recommend just creating the Text object ONCE, above the while loop,

scoreText = ...
scoreText.setTextColor(...)

and then inside of the WHILE loop, you can just call the .setText(...) method to change the text that is displaying within the object, rather than undrawing/drawing it every time.

scoreText.setText(f"Score: {score}")

This should eliminate any flicker/blinking.

answered by (15.6k points)
+1

Thank you!!!

...