本文整理汇总了Python中Convert.viewport_to_world方法的典型用法代码示例。如果您正苦于以下问题:Python Convert.viewport_to_world方法的具体用法?Python Convert.viewport_to_world怎么用?Python Convert.viewport_to_world使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Convert
的用法示例。
在下文中一共展示了Convert.viewport_to_world方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: use_discrete
# 需要导入模块: import Convert [as 别名]
# 或者: from Convert import viewport_to_world [as 别名]
def use_discrete(self, world, player, mouse_pos, viewport):
#TODO: different types of projectile
pos = player.pos[:]
pixel_player_pos = Convert.world_to_viewport(pos, viewport)
difference = (mouse_pos[0] - pixel_player_pos[0],
mouse_pos[1] - pixel_player_pos[1])
length = math.sqrt(difference[0] ** 2 + difference[1] ** 2)
normalized = [difference[0] / length * ToolMagicStaff.PROJECTILE_SPEED,
difference[1] / length * ToolMagicStaff.PROJECTILE_SPEED]
vel = [player.vel[0] + normalized[0],
player.vel[1] + normalized[1]]
damage_source = DamageSourceBullet(pos, 5, 0.5, vel, "img/projectiles/orb.png", player, 60)
world.create_entity(damage_source)
world.create_entity(EntityEnemy(Convert.viewport_to_world(mouse_pos, viewport), "img/enemies/pinky.png", 10)) #TODO: remove