import pygame
import Selection
import Round
import Winner
import Fighting
pygame.init()
screen = pygame.display.set_mode((640, 500))
def main():
process = 0
clock = pygame.time.Clock()
keepGoing = True
while keepGoing:
clock.tick(30)
for event in pygame.event.get():
if event.type == pygame.QUIT:
keepGoing = False
if process == 0:
Selection.main()
process += 1
elif process == 1:
Fighting.main()
process += 1
pygame.quit()
if __name__ == "__main__":
main()
出现的错误是
for event in pygame.event.get():
pygame.error: video system not initialized
它贯穿整个程序
Selection.main()
调用运行正常的程序,但当它关闭时,程序会在
clock.tick(30)
但之后停在
for event in pygame.event.get()
并抛出错误。那个
import Round
import Winner
还没有做任何事情,因为那些程序还没有编写。你知道吗
我运行了你的代码,把它缩小到基本的,不能复制。你确定你把pygame.退出()在正确的缩进级别?你知道吗
如果这样做,我可以复制相同的异常(注意pygame.退出不缩进)。这将杀死pygame对象,并在第一次进入run循环时引发异常。我将执行顺序标记为1-10,这样就可以清楚地知道它抛出异常的原因。你知道吗
当我将pygame初始化和screen对象创建移到main中,以及pygame.退出像这样打电话:
这也适用于:
相关问题 更多 >
编程相关推荐