本文整理汇总了Python中monster.Monster.getPos方法的典型用法代码示例。如果您正苦于以下问题:Python Monster.getPos方法的具体用法?Python Monster.getPos怎么用?Python Monster.getPos使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类monster.Monster
的用法示例。
在下文中一共展示了Monster.getPos方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: range
# 需要导入模块: from monster import Monster [as 别名]
# 或者: from monster.Monster import getPos [as 别名]
while p_go == False:
for i in range(3):
for j in range(3):
if [i, j] == player.getPos():
print('*', end="")
if j != 2:
print('|', end="")
else:
print(' ', end="")
if j != 2:
print('|', end="")
print()
if i != 2:
print('_ _ _')
print('Where do you want to go?(Up:u, Down:d, Left:l, Right:r)')
key_value = sys.stdin.readline().strip('\n')
p_go = player.move(key_value)
if player.getPos() == monster.getPos():
success = True
print('You enconter a monster and dead. Game over!')
if player.getPos() == exit.getPos():
success = True
print('Congrats, you leave the maze!')
elif wh_idx % 2 == 1:
m_go = False
while m_go == False:
m_go = monster.move(random.choice(['u','d','l','r']), exit.getPos())
if monster.getPos() == player.getPos():
success = True
print('You enconter a monster and dead. Game over!')
wh_idx = wh_idx + 1