pygame.key.get_pressed()pygame.error:视频系统未初始化

时间:2015-05-23 16:43:28

标签: python

while True:
    screen.fill(white)
    cooldown += 1

    # --- Event Processing
    pygame.draw.rect(screen, black, (0, 500, 1000, 200))

    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            pygame.quit()

        elif event.type == pygame.MOUSEBUTTONDOWN:
            # Fire a bullet if the user clicks the mouse button
            bullet = Bullet()
            # Set the bullet so it is where the player is
            bullet.rect.x = player.rect.x + 40
            bullet.rect.y = player.rect.y + 10
            # Add the bullet to the lists
            if cooldown > 49:
                all_sprites_list.add(bullet)
                bullet_list.add(bullet)
                cooldown = 0

    keys = pygame.key.get_pressed()

    def horzMoveAmt():
        ''' Amount of horizontal movement based on left/right arrow keys, moving the player events '''
        return (keys[K_d] - keys[K_a]) * HORZ_MOVE_INCREMENT

第248行,在game_loop中  keys = pygame.key.get_pressed()  pygame.error:视频系统未初始化  我的游戏有效,但是当我关闭游戏窗口时会出现此消息。为什么?

0 个答案:

没有答案