我正在通过“ Python Crash Course”制作游戏,但是在显示pygame窗口时遇到问题。看起来好像Python Launcher应用正在尝试启动,但没有任何反应,Python Launcher的图标在Dock中弹跳而已。
import sys
import pygame
def run_game():
#Initilize game and create a screen object.
pygame.init()
pygame.display.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:
sys.exit()
# Make the most recently drawn screen visible.
pygame.display.flip()
run_game()
有什么解决办法吗? 非常感谢您的帮助!
upd。我正在使用MacOS Catalina。