当我们运行代码时,Pygame 只显示黑屏

时间:2021-07-02 06:16:25

标签: python pygame

我实际上在做一个 pygame 项目,这是我的代码

import pygame
from pygame.locals import *

pygame.init()

screen_width = 564
screen_height = 636

screen = pygame.display.set_mode((screen_width, screen_height))
pygame.display.set_caption("Flappy Bird")


# load images
bg = pygame.image.load('img/bg.png')

run = True
while run:

    screen.blit(bg, (0, 0))

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

pygame.display.update()

pygame.quit()

我的问题是,每当我运行代码时,它只显示黑屏,实际上我是初学者,所以我对 python 了解不多,但请有人帮助我。

0 个答案:

没有答案
相关问题