Displaying the End Game Messages
Whether the player wins or loses, we need to let him know with a message onscreen. The
showtext() function takes a string as its argument and then uses Pygame to show it.
You can reuse this function in your own programs. To adapt it, the things you need to know are that freesansbold.ttf is the name of the font, 64 is the font size in points, PURPLE is the text color, WHITE is the background color for the text, and the center of the text is at pixel position X=220 and Y=200.
The values we’ve used position the text across the middle of the giant raspberry. The text is huge. We have room for only about nine characters in the game window, but that’s perfect for this game.
textsurface=fontObj.render(text, True, PURPLE, WHITE)
Now you know how to display text, you can create functions called
gameover() for when the player loses and
gamewon() for win the player wins. ...