I'm working on a project in pygame and the text is supposed to display a character's speech. I've got the text displayed, but it runs off the screen. I tried one way to text wrap, but it didn't move to the next line, so it just overlapped on the same line. I don't know if there is some sort of boundary or border I can set or text wrap. I could only find things for python, not pygame.
Here's what I have for the text
white = (255,255,255)
def text_objects(text, font):
textSurface = font.render(text, True, white)
return textSurface, textSurface.get_rect()
def words(text):
largeText = pygame.font.Font('freesansbold.ttf', 18)
TextSurf, TextRect = text_objects((text), largeText)
TextRect = ((13), (560))
screen.blit(TextSurf, TextRect)
` pygame.display.update()
words("This is just filler. Yup, filler to test if this will run off the screen. And apparently \n doesn't start a new line... Doo duh doo. Bum Dum pssst.")