<分区>
我的代码看起来像这样,它可以正常打开显示并使背景变白,但它拒绝显示我的文本。它也不会给出任何错误。
import pygame
import time
import random
pygame.init()
black = (0, 0, 0)
gameDisplay = pygame.display.set_mode((1250,700))
white = (255, 255, 255)
def text_objects(text, font, color):
textSurface = font.render(text, True, color,)
return textSurface, textSurface.get_rect()
def letter_input():
gameDisplay.fill(white)
smallText = pygame.font.Font("txt.ttf", 20)
textSurf, textRect = text_objects ("Please input something to say", smallText, black)
textRect.center = (11250/2), (700/2)
gameDisplay.blit(textSurf, textRect)
pygame.display.update()
letter_input()
pygame.display.set_caption("Sentence printer")
clock = pygame.time.Clock()
坦率地说,我只是对它为什么不这样做感到困惑。