MCPcopy
hub / github.com/CharlesPikachu/Games / showText

Method showText

cpgames/core/games/pacman/pacman.py:166–195  ·  view source on GitHub ↗
(self, cfg, screen, font, is_clearance, flag=False)

Source from the content-addressed store, hash-verified

164 return is_clearance
165 '''显示文字'''
166 def showText(self, cfg, screen, font, is_clearance, flag=False):
167 clock = pygame.time.Clock()
168 msg = 'Game Over!' if not is_clearance else 'Congratulations, you won!'
169 positions = [[235, 233], [65, 303], [170, 333]] if not is_clearance else [[145, 233], [65, 303], [170, 333]]
170 surface = pygame.Surface((400, 200))
171 surface.set_alpha(10)
172 surface.fill((128, 128, 128))
173 screen.blit(surface, (100, 200))
174 texts = [font.render(msg, True, cfg.WHITE),
175 font.render('Press ENTER to continue or play again.', True, cfg.WHITE),
176 font.render('Press ESCAPE to quit.', True, cfg.WHITE)]
177 while True:
178 for event in pygame.event.get():
179 if event.type == pygame.QUIT:
180 QuitGame()
181 if event.type == pygame.KEYDOWN:
182 if event.key == pygame.K_RETURN:
183 if is_clearance:
184 if not flag:
185 return
186 else:
187 self.run()
188 else:
189 self.run()
190 elif event.key == pygame.K_ESCAPE:
191 QuitGame()
192 for idx, (text, position) in enumerate(zip(texts, positions)):
193 screen.blit(text, position)
194 pygame.display.flip()
195 clock.tick(self.cfg.FPS)

Callers 1

runMethod · 0.95

Calls 3

runMethod · 0.95
QuitGameFunction · 0.85
tickMethod · 0.80

Tested by

no test coverage detected