当我添加更多代码时,为什么 Pygame 会一直关闭?

问题描述

所以基本上,当我在这个阶段拥有它时,一切都很好:

import pygame
from pygame.locals import *

pygame.init()

screen_width = 1000
screen_height = 1000

screen = pygame.display.set_mode((screen_width,screen_height))
pygame.display.set_caption('Platformer')






run = True
while run:

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

pygame.quit()

但是一旦我添加了这样的东西:

import pygame
from pygame.locals import *

pygame.init()

screen_width = 1000
screen_height = 1000

screen = pygame.display.set_mode((screen_width,screen_height))
pygame.display.set_caption('Platformer')

sun_img = pygame.image.load('img/sun.png')
bg_img = pygame.image.load('img/sky.png')







run = True
while run:
    

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





pygame.quit()

它只是立即打开和关闭。 我是代码的大新手,现在只是玩得开心,但这个问题真的很烦人,如果我能得到任何帮助,我将不胜感激!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)