如何在运行时重新启动我的 python 程序

问题描述

在我正在制作的游戏中。当您按“再次播放”时,我试图让程序重新启动,但没有任何反应

def quitgame():
    pygame.quit()
    quit()
intro = False
run = False

def stop_intro():
    global intro
    global run
    intro = False
    run = True

def respawn():
    global run
    run = False
    run = True


def dead():
    ####################################


    ####################################
    largeText = pygame.font.SysFont("comicsansms",115)
    TextSurf,TextRect = text_objects("You Died",largeText)
    TextRect.center = ((display_width / 2),(display_height / 2))
    screen.blit(TextSurf,TextRect)

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

        button("Play Again",40,450,100,50,green,bright_green,respawn)
        button("Quit",480,red,bright_red,quitgame)

        pygame.display.update()
        clock.tick(15)

然后在主循环中是我如何调用函数

if man.health == 0:
    dead()

我能得到这个问题的答案吗

解决方法

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

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

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