为什么赢了#ggame显示我的文字?

时间:2017-04-17 18:45:22

标签: python text pygame

我的代码看起来像这样,它打开显示器并使背景变白,但它拒绝显示我的文本。它也会给出任何错误。

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()

坦率地说,我很困惑为什么不会这样做。

1 个答案:

答案 0 :(得分:1)

textRect.center = (11250/2), (700/2)

在这里,您可以将rect的topleft坐标设置为(5625.0,350.0)以及gameDisplay之外的坐标。请尝试代替textRect.center = (500, 300)

相关问题