2016-03-01 19 views
0

我想要做的是,我想在初始窗口中選擇不同的小遊戲作爲選項。因此,無論用戶選擇何種遊戲選項,該遊戲都將在同一個窗口中運行。這是可能的,如果它是如何呢?我如何在一個.py文件中包含多個pygame程序,以便可以從同一個窗口訪問它們

+0

這是可能的,你可以做一個簡單的菜單中的第一個窗口。但是一般來說這不是一個好的做法,即使是一個遊戲只有一個文件。查看sourceforge上的python程序示例,瞭解人們如何構建代碼,分離模型,視圖,控制器,文檔,配置等。 – roadrunner66

回答

0

這可能是你在僞想要的東西:

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 
+0

謝謝,這應該適用於一些基本遊戲 –

相關問題