Efficient way of adding one character at a time from one string to another in Python -


I am currently creating a function using pygame that draws a message on the screen, one letter is each frame ( I.e. red hunting for October ). I know that I can slowly copy (or pass) large slices from the original string, but I know that this will be very resource-intensive. Is there a better way to do this?

Code, gradually using large slices:

  def full_screen_dialog_tt (thesurface, thefont, theclock, message, thebeep): i = 0 while (i & lt; Len (message): # theclock.tick (60) thesurface.fill ((0, 0, 0)) Start the string display thesurface.blit (thefont.render (message [i] + "_")) Pygame. Display.flip () thebeep.play () while (1): # the entire string is hereclock.tick (60) for event in pygame.events.get (): if event.type == MOUSEBUTTONDOWN: For return < / Code> 

In a place where you are deliberately slowing the game (for text fade -i ) - Does it really matter? You can cross the entire string, and change the display routine to display another letter in each frame.


Comments

Popular posts from this blog

paypal - How to know the URL referrer in PHP? -

oauth - Facebook OAuth2 Logout does not remove fb_ cookie -

wpf - Line breaks and indenting for the XAML of a saved FlowDocument? -