當前位置: 首頁>>代碼示例>>Python>>正文


Python Result.show方法代碼示例

本文整理匯總了Python中result.Result.show方法的典型用法代碼示例。如果您正苦於以下問題:Python Result.show方法的具體用法?Python Result.show怎麽用?Python Result.show使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在result.Result的用法示例。


在下文中一共展示了Result.show方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: FSMGame

# 需要導入模塊: from result import Result [as 別名]
# 或者: from result.Result import show [as 別名]
class FSMGame(FSM):
    def __init__(self):
        FSM.__init__(self, "FSM-Game")
        self.menu = Menu()
        self.gameResult = Result()
        self.numNPCs = 7

        self.musicMenu = loader.loadMusic("Eraplee Noisewall Orchestra - Bermuda Fire.ogg")
        self.musicMenu.setLoop(True)
        self.musicGame = loader.loadMusic("Echovolt - Nothing to Fear.ogg")
        self.musicGame.setLoop(True)

    def enterMenu(self):
        helper.show_cursor()
        self.menu.show()
        self.musicMenu.play()

    def exitMenu(self):
        self.menu.hide()
        self.musicMenu.stop()

    def enterSingleplayer(self):
        helper.hide_cursor()

        self.musicGame.play()

        self.world = World()

        self.player = Player()
        self.player.setPos(self.world.getStartPos(1))
        self.player.setTeam("Yellow")
        self.player.setColor(LPoint3f(1, 1, 0))

        #self.player.setSpectator(self.world.getSpectatorNode())

        # create non player characters
        self.npcs = []
        for i in range(self.numNPCs):
            self.npcs.append(NPC())
            self.npcs[i].setPos(self.world.getStartPos(i+2))
            self.npcs[i].setBunker(self.world.getBunker())
            if i < self.numNPCs/2:
                self.npcs[i].setTeam("Yellow")
                self.npcs[i].setColor(LPoint3f(1, 1, 0))
            else:
                self.npcs[i].setTeam("Blue")
                self.npcs[i].setColor(LPoint3f(0, 0, 1))

        for i in range(self.numNPCs):
            el = []
            if self.npcs[i].playerTeam != self.player.playerTeam:
                el.append(self.player)
            for j in range(self.numNPCs):
                if self.npcs[i].playerTeam != self.npcs[j].playerTeam:
                    el.append(self.npcs[j])
            self.npcs[i].setEnemies(el)


        number = OnscreenText(
            text = "",
            scale = 0.75,
            pos = (0, -0.1875),
            fg = (1,1,1,1),
            align = TextNode.ACenter)

        def startSingleplayer():
            number.destroy()
            self.world.run()
            self.player.run()
            for npc in self.npcs:
                npc.run()
            taskMgr.add(self.checkGameOver, "checkGameOver")

        def setNumber(num):
            number["text"] = str(num)
            number["scale"] = 0.75
        inter = number.scaleInterval(1.0, 0)
        # setup a sequence that will count down for us
        self.countdownSeq = Sequence(
            Func(setNumber, 3),
            inter,
            Func(setNumber, 2),
            inter,
            Func(setNumber, 1),
            inter,
            Func(setNumber, "GO"),
            inter,
            Func(startSingleplayer))
        self.countdownSeq.start()

    def exitSingleplayer(self):
        self.countdownSeq.finish()
        self.player.stop()
        for i in range(len(self.npcs)):
            self.npcs[i].stop()
        self.npcs = []
        self.world.stop()
        del self.world
        self.gameResult.hide()
        taskMgr.remove("checkGameOver")
#.........這裏部分代碼省略.........
開發者ID:grimfang,項目名稱:Paintball,代碼行數:103,代碼來源:fsmGame.py


注:本文中的result.Result.show方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。