9.9: The Usual Text Creation Code
- Page ID
- 14627
\( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)
# create the surfaces to hold game text gameOverSurf = BASICFONT.render('Game Over', True, WHITE) gameOverRect = gameOverSurf.get_rect() gameOverRect.center = (HALF_WINWIDTH, HALF_WINHEIGHT) winSurf = BASICFONT.render('You have achieved OMEGA SQUIRREL!', True, WHITE) winRect = winSurf.get_rect() winRect.center = (HALF_WINWIDTH, HALF_WINHEIGHT) winSurf2 = BASICFONT.render('(Press "r" to restart.)', True, WHITE) winRect2 = winSurf2.get_rect() winRect2.center = (HALF_WINWIDTH, HALF_WINHEIGHT + 30)
These variables contain Surface objects with the "Game Over", "You have achieved OMEGA SQUIRREL!", and "(Press "r" to restart.)" text that appears on the screen after the game ends (with either the player losing or winning).