How would I make it so that I can start a new line of text with pygame? For example if I have a variable and it has lots of text that doesn't all fit on the screen, how can I make it so that it appears on multiple lines. I tried using \n in between the text but it doesn't work. Here's an example of code:
import pygame
pygame.init()
display_width = 800
display_height = 600
black = (0,0,0)
white = (255,255,255)
gameDisplay = pygame.display.set_mode((display_width, display_height))
clock = pygame.time.Clock()
def text_objects(text, font):
textSurface = font.render(text, True, black)
return textSurface, textSurface.get_rect()
gameDisplay.fill(white)
text = "this is a lot of text and it won't all fit on the screen it needs to be on multiple lines but it doesn't right now and i need more text"
theText = pygame.font.Font("freesansbold.ttf", 20)
TextSurf, TextRect = text_objects(text, theText)
TextRect.center = (display_width/2, 10)
gameDisplay.blit(TextSurf, TextRect)
pygame.display.update()