Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/oracle/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 有人知道为什么我在运行此代码时会出现一个无响应的pygame窗口吗_Python_Pygame - Fatal编程技术网

Python 有人知道为什么我在运行此代码时会出现一个无响应的pygame窗口吗

Python 有人知道为什么我在运行此代码时会出现一个无响应的pygame窗口吗,python,pygame,Python,Pygame,您的缩进已关闭,或者至少是唯一明显的问题。我试过运行,但第5行的设置未定义。在您给出的内容中没有定义其他类。这里有正确的缩进。(必须切换pygame.display.flip()和ship.blitme()) 您的缩进已关闭,或者至少是唯一明显的问题。我试过运行,但第5行的设置未定义。在您给出的内容中没有定义其他类。这里有正确的缩进。(必须切换pygame.display.flip()和ship.blitme()) 由于while:块,您将永远无法到达超过sys.exit()行的任何对象。退出w

您的缩进已关闭,或者至少是唯一明显的问题。我试过运行,但第5行的设置未定义。在您给出的内容中没有定义其他类。这里有正确的缩进。(必须切换
pygame.display.flip()
ship.blitme()


您的缩进已关闭,或者至少是唯一明显的问题。我试过运行,但第5行的设置未定义。在您给出的内容中没有定义其他类。这里有正确的缩进。(必须切换
pygame.display.flip()
ship.blitme()


由于
while:
块,您将永远无法到达超过
sys.exit()
行的任何对象。退出while循环的唯一方法是退出游戏。检查缩进。您尚未将某些行放入
while
循环中。由于
while True:
块,您将永远无法到达任何超过
sys.exit()
行的内容。退出while循环的唯一方法是退出游戏。检查缩进。您尚未将某些行置于
while
循环中。
def run_game():
    """Initialise the game and create a screen object."""
    pygame.init() 
    ai_settings = Settings()

    screen = pygame.display.set_mode((ai_settings.screen_width,ai_settings.screen_height)) 

    ship = Ship(screen)

    pygame.display.set_caption("Alien Invasion")

    while True:
        for event in pygame.event.get():  
            if event.type == pygame.QUIT:
                sys.exit()

    #Redraw the screen for each pass through the loop. ie fill the screen with colour.
    screen.fill(ai_settings.bg_colour) 

    #Make the most recently drawn screen visible.
    pygame.display.flip() 
    # Will update the screen as game elements move around. Making the game look smooth.


    ship.blitme() # added after background so appears ontop of it.


run_game()
while True:
    for event in pygame.event.get():  
        if event.type == pygame.QUIT:
            sys.exit()

    #Redraw the screen for each pass through the loop. ie fill the screen with colour.
    screen.fill(ai_settings.bg_colour) 
    ship.blitme() # added after background so appears ontop of it.
    #Make the most recently drawn screen visible.
    pygame.display.flip() 
    # Will update the screen as game elements move around. Making the game look smooth.