繁体   English   中英

如何在单个.py文件中包含多个pygame程序,以便可以从同一窗口访问它们

[英]How can I include multiple pygame programs in a single .py file so they can be accessed from the same window

我想做的是,我想在初始窗口中提供不同的较小游戏作为选项供您选择。 因此,无论用户选择了哪个游戏选项,该游戏都将在同一窗口中运行。 那有可能吗?

这可能是您想要的伪代码:

class Menu():
    #Has all menu-related knick-knacks

def main(screen):
    if on_main_menu == True:
        Menu.draw(screen)
    if Menu.start_button_1.is_pressed:
        on_main_menu = False
        playing_game1 = True
    if Menu.start_button_2.is_pressed:
        on_main_menu = False
        playing_game2 = True

while playing_game1:
    #play the epic game
while playing_game2:
    #play the even more epic game

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM