title: Making a multi-line, real-time text renderer in pygame for a Visual Novel
body: <p>I've been trying to make a multi-line text renderer that renders in real-time with pygame. I've basically successfully made one, however the text-renderer I've made MUST ALWAYS have 3 lines of text otherwise it won't render.</p>
  <p>What I'd like to do is to have a text renderer that can render as many lines that's inputted into it then have those lines render in real time.</p>
  <p>additionally, if it's possible, I'd also like the renderer to split lines based on the maximum size of an image. namely, a textBox for a Visual Novel</p>
  <p>The function will be used as a text renderer for a visual novel to be clear</p>
  <h1>Old text renderer</h1>
  <pre><code>def textRendererOld(string, char):
          text1, text2, text3 = string.split('\n', 3)
          blit1, blit2, blit3 = &quot;&quot;, &quot;&quot;, &quot;&quot;
      
          # remember to add a confirm token so that the text renders consecutively from text1 to text3
      
          for i in range(len(text1)):
              blit1 += text1[i]
              textSurface = charFonts[char].render(blit1, True, WHITE)
      
              DISPLAY.blit(textSurface, (TEXT_X_POS, TEXT_Y_POS))
              pygame.display.update()
              pygame.time.wait(TEXT_RENDER_SPEED)
      
          for i in range(len(text2)):
              blit2 += text2[i]
              textSurface = charFonts[char].render(blit2, True, WHITE)
      
              DISPLAY.blit(textSurface, (TEXT_X_POS, TEXT_Y_POS + PARAGRAPH_BREAK_GAP))
              pygame.display.update()
              pygame.time.wait(TEXT_RENDER_SPEED)
      
          for i in range(len(text3)):
              blit3 += text3[i]
              textSurface = charFonts[char].render(blit3, True, WHITE)
      
              DISPLAY.blit(textSurface, (TEXT_X_POS, TEXT_Y_POS + PARAGRAPH_BREAK_GAP * 2))
              pygame.display.update()
              pygame.time.wait(TEXT_RENDER_SPEED)
  </code></pre>
  <h1>My attempt at a multi-line text rederer</h1>
  <pre><code>def textRenderer(dialogue, character):
  
      textLines = []
      talkText = dialogue.split('\n', -1)
      textLines.append(talkText)
  
  
  
   for line in len(textLines):
          text = ''
          ParagraphBreak = 0
          for i in range(len(textLines)):
              text += textLines[line]
              textSurface = charFonts[character].render(text, True, WHITE)
  
              DISPLAY.blit(textSurface, (TEXT_X_POS, TEXT_Y_POS))
              pygame.display.update()
              pygame.time.wait(TEXT_RENDER_SPEED)
  
              ParagraphBreak = ParagraphBreak + PARAGRAPH_BREAK_GAP
  </code></pre>