当前位置: 首页>>代码示例>>Python>>正文


Python Menu.addPanel方法代码示例

本文整理汇总了Python中Menu.addPanel方法的典型用法代码示例。如果您正苦于以下问题:Python Menu.addPanel方法的具体用法?Python Menu.addPanel怎么用?Python Menu.addPanel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Menu的用法示例。


在下文中一共展示了Menu.addPanel方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: world

# 需要导入模块: import Menu [as 别名]
# 或者: from Menu import addPanel [as 别名]
class world():
    def __init__(self):
        self.pauseMenu = Menu()
        self.statsMenu = Menu()
        self.weaponMenu = Menu()
        self.armorMenu = Menu()
        self.promptMenu = Menu()
        self.rmin = 400
        self.rmax = 800
        self.bgtimer = random.randint(self.rmin, self.rmax)
        self.dirtimer = random.randint(self.rmin, self.rmax)
        self.max_chans = 100
        pygame.mixer.set_num_channels(self.max_chans)
        self.smanager = SoundManager(self.max_chans)
        amb = pygame.mixer.Sound('ambient2.ogg')
        self.ambch = pygame.mixer.Channel(self.smanager.get())
        br = pygame.mixer.Sound('charbreath.ogg')
        wk = pygame.mixer.Sound('charwalk.ogg')
        rn = pygame.mixer.Sound('charrun.ogg')
        gr = pygame.mixer.Sound('chargrunt.ogg')
        hw = pygame.mixer.Sound('hitwall2.ogg')
        hb = pygame.mixer.Sound('heartbeat.ogg')
        hbf = pygame.mixer.Sound('heartbeat_fast.ogg')
        
        pygame.mixer.Sound('armor_aquire.ogg')
        bgfx = [pygame.mixer.Sound('roar_distant.ogg'),\
                pygame.mixer.Sound('ambient3.ogg'),\
                pygame.mixer.Sound('bug_alien.ogg')]
        self.bgsound = RadarSound(bgfx, self.smanager.get())
        self.screen = pygame.display.get_surface()
        self.srect = self.screen.get_rect()
        self.bg = pygame.Surface((self.srect.width, self.srect.height))
        self.bg.fill((0, 75, 75))
        self.bgrect = self.bg.get_rect()
        self.fog = pygame.Surface((self.srect.width, self.srect.height))
        self.fog.fill((128, 128, 128))
        self.fogrect = self.fog.get_rect()
        self.fog.set_alpha(245)
        self.char = Char(self.smanager.get(), [wk, rn], self.smanager.get(), [br, gr, hw],\
                 self.smanager.get(), [hb, hbf])
        self.weaponChannel = self.smanager.get()
        self.armorChannel = self.smanager.get()
        self.char.getWeapon(Katana(self.char, self.weaponChannel))
        self.char.getWeapon(Pistol(self.char, self.weaponChannel))
        self.char.equipWeapon(0)
        self.char.getArmor(lightArmor(self.armorChannel))
        self.char.equipArmor(0)
        self.chars = pygame.sprite.RenderUpdates(self.char)
        self.enemies = pygame.sprite.RenderUpdates()
        self.lmarks = pygame.sprite.RenderUpdates()
        self.dirfx = pygame.sprite.RenderUpdates()
        self.dirfxs = pygame.sprite.RenderUpdates()
        self.spawner = Spawner(self.char, self.smanager, self.enemies, self.lmarks,\
                               self.dirfx, self.dirfxs, self.weaponChannel, self.armorChannel)
        self.menuInit()
        self.ambch.set_volume(.5)
        self.ambch.play(amb, -1)
        self.clock = pygame.time.Clock()
        self.bgdis()
        pygame.display.flip

    def menuInit(self):
        win = re.compile(r"win")
        linux = re.compile(r"linux")
        if win.match(sys.platform) != None:
            self.menuInitWindows()
        elif linux.match(sys.platform) != None:
            self.menuInitLinux()
    
    def menuInitWindows(self):
        tsize = 60
        osize = 60
        panel = Panel((200, 200), (self.srect.width - 200, self.srect.height - 200))
        panel.setTSize(40)
        panel.setOSize(50)
        self.promptMenu.addPanel(panel)
        panel.initOptions((panel.getCenter()[0] - 15, 70), 3, 60)
        panel.setTexts([Text((0, 0), panel.tsize)])
        
        panel = Panel((400, 720), (0,0))
        panel2 = Panel((880, 720), (400, 0))
        panel.setTSize(tsize)
        panel.setOSize(osize)
        panel2.setTSize(tsize)
        panel2.setOSize(osize)
        self.pauseMenu.addPanel(panel)
        self.pauseMenu.addPanel(panel2)
        panel2.setTexts([Text((0, 0), 100)])
        panel.initOptions((panel.getCenter()[0] - 15, 100), 6)
        panel.addOptions([Option("1: Stats", panel.osize, phandle = pauseMenuPrintStats,\
                                 pargs = [self.pauseMenu, self.char]),\
                          Option("2: Weapons", panel.osize, handle = pauseMenuRunWeapons,\
                                 args = [self.weaponMenu, self.char, self.promptMenu]),\
                          Option("3: Armor", panel.osize, handle = pauseMenuRunArmor,\
                                 args = [self.armorMenu, self.char, self.promptMenu])])

        panel = Panel((400, 720), (0,0))
        panel2 = Panel((880, 720), (400, 0))
        panel.setTSize(tsize)
        panel.setOSize(osize)
#.........这里部分代码省略.........
开发者ID:gcastellanos,项目名称:radar,代码行数:103,代码来源:worldClass.py

示例2: Menu

# 需要导入模块: import Menu [as 别名]
# 或者: from Menu import addPanel [as 别名]
pygame.display.set_mode((1200, 720))

#menu constructors
mainMenu = Menu()
menu2 = Menu()
pauseMenu = Menu()
statsMenu = Menu()

#menu initialization
s = open('Text.py', 'r').read()
tpanel = Panel((400, 720), (0, 0))
tpanel.setOptions([Option((tpanel.getCenter()[0] - 15, 100), "Button 1", button1Click, [mainMenu]),\
                   Option((tpanel.getCenter()[0] - 15, 200), "Button 2", button2Click, []),\
                   Option((tpanel.getCenter()[0] - 15, 300), "Button 3", button3Click, [menu2]),\
                   Option((tpanel.getCenter()[0] - 15, 400), "Exit", button4Click, [])])
mainMenu.addPanel(tpanel)
mainMenu.setFocus(0)
tpanel = Panel((800, 720), (400, 0))
tpanel.setTexts([Text((0, 0), 25, maxwidth = tpanel.getMaxWidth())])
mainMenu.addPanel(tpanel)
mainMenu.addText(s, 1, 0)

panel = Panel((1200, 720), (0, 0))
panel.setTexts([Text((0, panel.getCenter()[1]), 50)])
menu2.addPanel(panel)
menu2.addText("You Pressed button 3!!", 0, 0)

panel = Panel((400, 720), (0,0))
panel2 = Panel((800, 720), (400, 0))
panel.setOptions([Option((panel.getCenter()[0] - 15, 100), "1: Stats", pauseMenuRunStats, [statsMenu])])
pauseMenu.addPanel(panel)
开发者ID:gcastellanos,项目名称:radar,代码行数:33,代码来源:MenuInit.py


注:本文中的Menu.addPanel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。