Python: How do you make a title screen on pygame?

2019-09-06 21:36发布

问题:

How would you put in a title screen/ending screen in pygame? Using the Enter key to continue and the Esc key to quit.

I have a title screen that I personally made off of photoshop and I'd like to just insert it into the beginning of the game and just have the user either press Enter or Esc. How would I do that?

回答1:

There are many Pygame resources out there on the web. A recent book released by Al Sweigart, Making Games with Python and Pygame has some examples of what you are describing.

In particular, take a look at the following sample program. This has some functions that will accomplish what you want to do, namely the showStartScreen(), checkForKeyPress(), and drawPressKeyMsg() functions.