【发布时间】:2018-05-29 20:21:54
【问题描述】:
运行这段代码后,出现错误:
pygame.error: video system not initialized
我的代码:
import sys
import pygame
def run_game():
# Initialize game and create a screen object.
pygame.init()
screen = pygame.display.set_mode((1200, 800))
pygame.display.set_caption("Alien Invasion")
# Start the main loop for the game.
while True:
# Watch for keyboard and mouse events.
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
# Make the most recently drawn screen visible.
pygame.display.flip()
run_game()
谁能帮我解释一下这个错误是什么意思以及如何纠正它?
【问题讨论】:
-
欢迎使用 stackoveflow 。阅读此文档:stackoverflow.com/help/how-to-ask 了解如何在 stackoveflow 中提问