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

Class HelpText

PythonAPI/examples/manual_control.py:650–672  ·  view source on GitHub ↗

Helper class to handle text output using pygame

Source from the content-addressed store, hash-verified

648
649
650class HelpText(object):
651 """Helper class to handle text output using pygame"""
652 def __init__(self, font, width, height):
653 lines = __doc__.split('\n')
654 self.font = font
655 self.line_space = 18
656 self.dim = (780, len(lines) * self.line_space + 12)
657 self.pos = (0.5 * width - 0.5 * self.dim[0], 0.5 * height - 0.5 * self.dim[1])
658 self.seconds_left = 0
659 self.surface = pygame.Surface(self.dim)
660 self.surface.fill((0, 0, 0, 0))
661 for n, line in enumerate(lines):
662 text_texture = self.font.render(line, True, (255, 255, 255))
663 self.surface.blit(text_texture, (22, n * self.line_space))
664 self._render = False
665 self.surface.set_alpha(220)
666
667 def toggle(self):
668 self._render = not self._render
669
670 def render(self, display):
671 if self._render:
672 display.blit(self.surface, self.pos)
673
674
675# ==============================================================================

Callers 1

__init__Method · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected