【发布时间】:2017-06-14 00:55:36
【问题描述】:
我收到以下错误:
回溯(最近一次通话最后一次):
文件“D:\ninja_car.py”,第 32 行,在
gameDisplay.fill(白色)
NameError: name 'white' 未定义
我的代码:
import pygame
pygame.init()
display_width = 800
display_height = 600
gameDisplay = pygame.display.set_mode((display_width,display_height))
pygame.display.set_caption('Ninja Game')
clock = pygame.time.Clock()
carImg = pygame.image.load('car.png')
def car(x,y):
gameDisplay.blit(carImg,(x,y))
x = (display_width * 0.45)
y = (display_height * 0.8)
crashed = False
while not crashed:
for event in pygame.event.get():
if event.type == pygame.QUIT:
crashed = True
gameDisplay.fill(white) # here
car(x,y)
pygame.display.update()
clock.tick(60)
pygame.quit()
quit()
这里有什么问题?我正在使用 Python 3.4。试图将背景设置为白色,但它给出了该错误。
【问题讨论】:
-
你在哪里定义了白色变量?
标签: python python-3.x pygame