```import pygame
def run_game():
pygame.init()
pygame.display.set_caption("Alien Invasion")
screen = pygame.display.set_mode((1200,800))
bg_color = (230, 230, 230)
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit()
screen.fill(bg_color)
pygame.display.flip()
run_game()
Python学习,根据书《Python编程:从入门到实践》学习,为啥不变颜色,理论上应该是灰色,但是它不变色,是黑色
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
1条回答 默认 最新
Python-ZZY 2021-10-06 13:31关注你打错了!代码缩进有问题
import pygame def run_game(): pygame.init() pygame.display.set_caption("Alien Invasion") screen = pygame.display.set_mode((1200,800)) bg_color = (230, 230, 230) while True: for event in pygame.event.get(): if event.type == pygame.QUIT: sys.exit() screen.fill(bg_color) pygame.display.flip() ''' 上面这两行缩进出问题了 ''' run_game()评论 打赏 举报解决 1无用