Для отображения текста в Pygame, установить шрифт, визуализации, положить на экран. Чтобы заменить текст, вам просто нужно удалить предыдущий текст и поставить новый. Чтобы использовать многоцветный текст, вы должны поместить один цветной текст несколько раз.
Я сделал пример кода из вашего вопроса. Примечание: в этом коде красный текст всегда остается желтым.
import pygame
import sys
import time
pygame.init()
screen = pygame.display.set_mode((640, 480))
done = False
font = pygame.font.SysFont("comicsansms", 72)
# position offset to display text
pos_x = 100
pos_y = 0
red_yellow = [
[' 0', ''],
[' 0', ' 0'],
[' 0', ' 0'],
[' 0', ' 0'],
[' 0', ' 0'],
[' 0', ' 0'],
[' 0', ' 0'],
[' 0', ' 0'],
[' 0', ' 0'],
[' 0', ' 0'],
[' 0', ' 0'],
]
while not done:
for event in pygame.event.get():
if event.type == pygame.QUIT:
done = True
if event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE:
done = True
screen.fill((255, 255, 255))
for t_r, t_y in red_yellow:
# screen.fill((255, 255, 255))
text_r = font.render(t_r, True, (255, 0, 0)) # red
text_y = font.render(t_y, True, (255, 255,0)) # yellow
screen.blit(text_r, (pos_x, pos_y)) # put red text
screen.blit(text_y, (pos_x + text_r.get_width(), pos_y)) # put yellow right to the red text
pygame.display.flip()
time.sleep(0.2)
pos_y += text_r.get_height()
# break
pygame.quit()
sys.exit()