Jan-05-2023, 07:35 PM
(This post was last modified: Jan-05-2023, 07:37 PM by deanhystad.)
If you split the message into lines you only have to change the y location for each line. Each line will be centered at the same x location. The words automatically get positioned correctly inside the lines. You should not draw them a word at a time.
def blit_text(surface, message, pos, font, color=pygame.Color('black')): x, y = pos for line in message.split('\n'): text = font.render(word, 0, color) width, height = text.get_size() surface.blit(text, (x - width/2, y - height/2)) y += height + 2.