首页 > 解决方案 > 如何打开无法启动的pygame窗口?

问题描述

我正在从“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()

知道如何解决吗?非常感谢您的帮助!

更新。我正在使用 MacOS Catalina。

标签: pythonpython-3.xmacospygamemacos-catalina

解决方案


推荐阅读