display text with pygame code example
Example: python how to write text in pygame
import pygame
pygame.init()
window = pygame.display.set_mode((500, 500))
def set_text(string, coordx, coordy, fontSize):
font = pygame.font.Font('freesansbold.ttf', fontSize)
text = font.render(string, True, (0, 0, 0))
textRect = text.get_rect()
textRect.center = (coordx, coordy)
return (text, textRect)
window.fill((255, 255, 255))
totalText = set_text("Text in Pygame!", 250, 250, 60)
window.blit(totalText[0], totalText[1])
pygame.display.update()