微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决当我添加更多代码时,为什么 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 举报,一经查实,本站将立刻删除。