| 650 | class 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 |