本文整理汇总了Python中enemy.Enemy.add_waypoint方法的典型用法代码示例。如果您正苦于以下问题:Python Enemy.add_waypoint方法的具体用法?Python Enemy.add_waypoint怎么用?Python Enemy.add_waypoint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类enemy.Enemy
的用法示例。
在下文中一共展示了Enemy.add_waypoint方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: init_new_map
# 需要导入模块: from enemy import Enemy [as 别名]
# 或者: from enemy.Enemy import add_waypoint [as 别名]
def init_new_map(self):
# temp tables
objects = []
enemies_data = []
enemies = []
hero = 0
# get all objects
for sprite_layer in self.sprite_layers:
if sprite_layer.is_object_group:
objects.append(sprite_layer.objects)
# sort all different variables
pixel_width = self.world_map.pixel_width
pixel_height = self.world_map.pixel_height
for object in objects:
if object[0].type == "hero":
position = (int(object[0].x), int(object[0].y))
sprite_size = (int(object[0].properties["sprite_width"]), int(object[0].properties["sprite_height"]))
hero = Character(object[0].properties["sprite"], position, sprite_size, (pixel_width, pixel_height))
else:
enemies_data.append(object)
for enemy_data in enemies_data:
new_enemy = Enemy()
for object in enemy_data:
if object.type == "enemy":
new_enemy.set_sprite(
object.properties["sprite"],
object.properties["sprite_width"],
object.properties["sprite_height"],
)
elif object.type == "waypoint":
xPosition = int(object.x // self.sprite_layers[0].tilewidth) * self.sprite_layers[0].tilewidth
yPosition = int(object.y // self.sprite_layers[0].tileheight) * self.sprite_layers[0].tileheight
new_enemy.add_waypoint((xPosition, yPosition, int(object.properties["number"])))
new_enemy.init()
enemies.append(new_enemy)
return (hero, enemies)