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

Class FadingText

PythonAPI/examples/manual_control.py:621–642  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

619
620
621class FadingText(object):
622 def __init__(self, font, dim, pos):
623 self.font = font
624 self.dim = dim
625 self.pos = pos
626 self.seconds_left = 0
627 self.surface = pygame.Surface(self.dim)
628
629 def set_text(self, text, color=(255, 255, 255), seconds=2.0):
630 text_texture = self.font.render(text, True, color)
631 self.surface = pygame.Surface(self.dim)
632 self.seconds_left = seconds
633 self.surface.fill((0, 0, 0, 0))
634 self.surface.blit(text_texture, (10, 11))
635
636 def tick(self, _, clock):
637 delta_seconds = 1e-3 * clock.get_time()
638 self.seconds_left = max(0.0, self.seconds_left - delta_seconds)
639 self.surface.set_alpha(500.0 * self.seconds_left)
640
641 def render(self, display):
642 display.blit(self.surface, self.pos)
643
644
645# ==============================================================================

Callers 1

__init__Method · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected