本文整理汇总了Python中monster.Monster.definir_position方法的典型用法代码示例。如果您正苦于以下问题:Python Monster.definir_position方法的具体用法?Python Monster.definir_position怎么用?Python Monster.definir_position使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类monster.Monster
的用法示例。
在下文中一共展示了Monster.definir_position方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: handle_event
# 需要导入模块: from monster import Monster [as 别名]
# 或者: from monster.Monster import definir_position [as 别名]
def handle_event(self):
if self.story["action"] == "death":
if self.story["sprite"] == "player":
self.game.story_manager.display_speech(["GAME OVER"], "bottom")
self.game.story_manager.set_unblockable(False)
self.game.perso.kill()
elif self.story["sprite"]:
sprite_name = self.story["sprite"]
sprite = self.game.layer_manager.get_sprite(sprite_name)
time.sleep(2)
sprite.kill()
elif self.story["action"] == "spawn":
if self.story["spawn_type"] == "npc":
npc = Npc(self.story["name"],
os.path.join(self.game.config.get_sprite_dir(),
self.story["sprite_img"]),
self.story["destination"],
self.game.layer_manager["npcs"])
npc.definir_position(self.story["destination"][0],
self.story["destination"][1])
else:
monster = Monster(self.story["name"],
os.path.join(self.game.config.get_sprite_dir(),
self.story["sprite_img"]),
self.story["destination"],
self.game.layer_manager["monster"])
monster.definir_position(self.story["destination"][0],
self.story["destination"][1])
elif self.story["action"] == "speech":
self.game.story_manager.display_speech(self.story['text'],
self.story['position'])
elif self.story["action"] == "move":
self.game.story_manager.blocking = True
self.game.story_manager.set_unblockable(False)
sprite = self.game.layer_manager.get_sprite(self.story["sprite"])
dest = self.story["destination"]
sprite.saveLastPos()
if sprite.collision_rect.x != dest[0]:
if sprite.collision_rect.x < dest[0]:
sprite.move(sprite.speed * sprite.accel, 0, "right")
else:
sprite.move(-(sprite.speed * sprite.accel), 0, "left")
self.game.story_manager.events.insert(0, self)
return
if sprite.collision_rect.y != dest[1]:
if sprite.collision_rect.y < dest[1]:
sprite.move(0, sprite.speed * sprite.accel, "down")
else:
sprite.move(0, -(sprite.speed * sprite.accel), "up")
self.game.story_manager.events.insert(0, self)
return
if self.game.story_manager.blocking:
self.game.story_manager.set_unblockable(True)
self.game.story_manager.blocking = False