Interactive Animations and Games

Can anyone tell my why the code isn’t working the way we think it should? We want the text to stay on after the “g” is pressed.

Yes, the issue is that the text() only runs once when the “g” key is pressed. On the next frame, draw () runs again and clears the screen (redrawing the sprites), so the text disappears. Use a variable to remember that the “g” key has been pressed, and then always show the text afterward.

Here is a solution!