I'm currently making a function using pygame that draws a message on the screen, adding one character each frame (i.e. The Hunt for Red October). I know that I could simply copy (or pass) gradually bigger slices from the original string, but I know that it would be very resource-intensive. Is there a better way to do this?
Code, using gradually bigger slices:
def full_screen_dialog_tt(thesurface, thefont, theclock, message, thebeep):
i = 0
while(i < len(message)): # Initialize the string display
theclock.tick(60)
thesurface.fill((0, 0, 0))
thesurface.blit(thefont.render(message[i]+"_"))
pygame.display.flip()
thebeep.play()
while(1): # Whole string is here now
theclock.tick(60)
for event in pygame.events.get():
if event.type == MOUSEBUTTONDOWN: return