本文整理汇总了Python中map.Map.pack方法的典型用法代码示例。如果您正苦于以下问题:Python Map.pack方法的具体用法?Python Map.pack怎么用?Python Map.pack使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类map.Map
的用法示例。
在下文中一共展示了Map.pack方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Game
# 需要导入模块: from map import Map [as 别名]
# 或者: from map.Map import pack [as 别名]
class Game(State):
"""The main state : the Game is run in this class"""
def __init__(self, parent, machine, level = 1):
super().__init__(parent, machine)
self.changeLevel(level)
self.done = False
self.map.bind("<Escape>", lambda e: self.machine.push_later(PauseState(self.parent, self.machine)))
"""The function to change the level"""
def changeLevel(self, level):
self.level = level
filename = "Levels/niveau" + str(level) + ".txt"
try:
self.map.load(filename)
except AttributeError:
self.map = Map(self, filename)
self.map.pack(fill=tk.BOTH, expand=tk.YES)
except FileNotFoundError:
self.machine.push_later(TextState(self.parent, self.machine, "Youuuuuuuuu WIN: No more level!"))
self.pop()
self.done = True
def update(self, dt):
try:
self.map.update(dt)
except Victory:
self.changeLevel(self.level + 1)
if not self.done:
self.machine.push_later(TextState(self.parent, self.machine, "Youuuuuuu WIN! Next level: " + str(self.level)))
except Death:
self.machine.push_later(TextState(self.parent, self.machine, "You're dead bitch!"))
self.pop()
def focus(self):
self.map.focus_set()
def show(self):
self.map.show()