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


Python Game.new方法代码示例

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


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

示例1: ViewMain

# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import new [as 别名]

#.........这里部分代码省略.........
        else:
            text = "Congratulations "+ self.game.playerName + \
                   ".\nYour score is "+ `self.game.story.score` + "!!"
        self.gui.scores.setText(text)
        self.displayHighScores()
        self.setStackWidgetIndex(self.SCORE_PAGE)
    
    def displayHighScores(self):
        """After player wins the game, we want to display
           the 10th high scores on screen
        """
        text = ""
        markCurr = 0 # Mark curr player if he made to the top ten list
        debug("len of scoreLIst is: ", len(self.game.scoreList))
        for prevPlayer in self.game.scoreList:
            prevName = prevPlayer[0]
            prevScore = prevPlayer[1]
            if (markCurr == 0 and prevName == self.game.playerName \
            and prevScore == self.game.story.score):
                markCurr = 1
                text = text + prevPlayer[0] + 40*"."  + `prevPlayer[1]` + "  *****" + "\n"
            else:
                text = text + prevPlayer[0] + 40*"."  + `prevPlayer[1]` + "\n"
        self.gui.topTenScores.setText(text)
        self.game.writeScoreToFile() 
 

    def enterName(self):
        """Name enter dialog"""
        playerName, ok = QInputDialog.getText(self, 'Enter Name Dialog', 
            'Please enter your name:')

        if ok and playerName!="":
            self.newGame()
            self.game.playerName = playerName
        else:
            pass
            
    def loadFileDialog(self):
        """pop up the loading dialog for players to choose saved file"""
        fd = QFileDialog()
        filename = fd.getOpenFileName(None, "Load Saved Game",
                                      "saves", "MapMaster Save files (*.save)")

        if isfile(filename):
            self.loadGame(filename)
        
            self.gameWasLoaded = True
            self.filename = filename
        else:
            debug("invalid file")

    def loadGame(self, filename):
        """pop up the loading dialog for players to choose saved file"""

        self.setStackWidgetIndex(self.GAME_PAGE)
        self.game = Game() 
        self.connectGame()
        self.game.load(filename)
        debug("Initializing the saved game...")
        
        
        self.overlays['latLongOverlay'] = self.addOverlay(
                    normpath("images/latOverlayNew.png"))
        self.overlays['colorOverlay'] = self.addOverlay(
                    normpath("images/colorOverlay.png"))
开发者ID:hackerj,项目名称:Treasure-Hunting-Game,代码行数:70,代码来源:ViewMain.py


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