本文整理汇总了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"))