简体   繁体   English

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

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

What I want to do is, I want to present different smaller games as options on the initial window to choose from. 我想做的是,我想在初始窗口中提供不同的较小游戏作为选项供您选择。 So whatever the game option user selects, that game will run in the same window. 因此,无论用户选择了哪个游戏选项,该游戏都将在同一窗口中运行。 Is that possible and if it is then how? 那有可能吗?

This could be what you want in pseudocode: 这可能是您想要的伪代码:

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.

相关问题 如何将多个.py文件捆绑为一个.exe文件? - How can I bundle multiple .py files into single .exe file? 如何将 .py 文件中的变量导入列表,以便可以使用该列表中的随机模块? - How can I import variables from a .py file into a list, so that I can use the random module on that list? 如何将python + pygame程序打包为可执行文件? - How can I package python+pygame programs as executables? 如何使用 matplotlib 在同一窗口中读取文件生成多个图 - Pyhton - How can I generate multiple plots from reading a file in the same window using matplotlib - Pyhton 如何从另一个脚本更新 pygame window? - How can I update pygame window from another script? 如何将控制台插入pyGame窗口? - How can I insert a console in to a pyGame Window? 如何创建一个可以由在不同计算机上运行同一程序的多个人访问的数据库? - How can I make a database that can be accessed by multiple people running the same program on different computers? 如何使用Web2py在html中包含python窗口或框架? - How I can include python Window or frame in html using Web2py? 更改为 pygame 窗口时如何关闭 tkinter 窗口? - How can I close a tkinter window when changing to a pygame window? 两个python / pygame程序在同一窗口中运行 - Two python/pygame programs to run in the same window
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM