MCPcopy Create free account
hub / github.com/AdaCompNUS/summit / HelpText

Class HelpText

PythonAPI/examples/no_rendering_mode.py:229–252  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

227
228
229class HelpText(object):
230 def __init__(self, font, width, height):
231 """Renders the help text that shows the controls for using no rendering mode"""
232 lines = __doc__.split('\n')
233 self.font = font
234 self.dim = (680, len(lines) * 22 + 12)
235 self.pos = (0.5 * width - 0.5 * self.dim[0], 0.5 * height - 0.5 * self.dim[1])
236 self.seconds_left = 0
237 self.surface = pygame.Surface(self.dim)
238 self.surface.fill(COLOR_BLACK)
239 for n, line in enumerate(lines):
240 text_texture = self.font.render(line, True, COLOR_WHITE)
241 self.surface.blit(text_texture, (22, n * 22))
242 self._render = False
243 self.surface.set_alpha(220)
244
245 def toggle(self):
246 """Toggles display of help text"""
247 self._render = not self._render
248
249 def render(self, display):
250 """Renders the help text, if enabled"""
251 if self._render:
252 display.blit(self.surface, self.pos)
253
254
255# ==============================================================================

Callers 1

_init_hud_paramsMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected