【发布时间】:2018-11-20 19:28:38
【问题描述】:
问题 - 我正在尝试为 simon 说游戏制作开始菜单并尝试首先显示一些文本,但是除了游戏屏幕变白(应该会发生)之外什么都没有显示。我看过类似的问题,但它们似乎没有帮助。
程序应该只在屏幕上用黑色字体显示“西蒙说”
代码:
import pygame,random,pickle,time
WHITE = (255,255,255)
BLACK = (0,0,0)
RED = (255,0,0)
GREEN = (0,255,0)
BLUE = (0,0,255)
YELLOW = (255,255,0)
PURPLE = (128,0,128)
CYAN = (0,255,255)
ORANGE = (255,165,0)
PINK = (255,192,203)
pygame.init()
logo = pygame.image.load("logo.png")
pygame.display.set_icon(logo)
pygame.display.set_caption("Simon Says")
screen = pygame.display.set_mode((1280,720))
def textObjects(text,font):
textSurface = font.render(text,True,BLACK)
return textSurface, textSurface.get_rect()
def displayText(text):
fontInfo = pygame.font.Font(None,100)
textSurf, textSize = textObjects(text,fontInfo)
textSize.center = ((1280/2),(720/2))
screen.blit(textSurf,textSize)
pygame.display.update()
def startMenu():
displayText('Simon Says')
def main():
startMenu()
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
screen.fill(WHITE)
pygame.display.update()
pygame.display.flip()
main()
也尝试使用 pygame.display.flip() ,但也没有用
【问题讨论】:
标签: python text pygame game-development