本文整理汇总了Python中level.Level.noPower方法的典型用法代码示例。如果您正苦于以下问题:Python Level.noPower方法的具体用法?Python Level.noPower怎么用?Python Level.noPower使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类level.Level
的用法示例。
在下文中一共展示了Level.noPower方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from level import Level [as 别名]
# 或者: from level.Level import noPower [as 别名]
class LevelController:
""" Controller class for the level """
def __init__(self):
""" Initialize the Level Controller """
self.level = Level(4)
self.minefield_view = MinefieldView(self.level.minefield, self.level.drone)
self.actions = {KAO_UP:self.level.drone.up,
KAO_DOWN:self.level.drone.down,
KAO_LEFT:self.level.drone.left,
KAO_RIGHT:self.level.drone.right,
ord('s'):self.level.drone.scan,
ord('d'):self.level.drone.defuse,
ESCAPE:self.stopRunning}
def run(self):
""" Run the controller """
self.running = True
self.loop()
def loop(self):
""" Run the controller main loop """
while self.running:
print self.minefield_view
self.processInput()
self.checkGameOver()
def processInput(self):
""" Process the input """
kao_char = getch()
if kao_char in self.actions:
self.actions[kao_char]()
def stopRunning(self):
""" Stop the Controller from running """
self.running = False
def checkGameOver(self):
""" Check if the Game is Over """
if self.level.lost():
self.stopRunning()
if self.level.destroyed():
print "Destroyed!"
elif self.level.noPower():
print "No Power!"
print "Game Over\r"
elif self.level.won():
self.stopRunning()
print "Congratulations! You won!"