本文整理汇总了Python中object.Object.move_left方法的典型用法代码示例。如果您正苦于以下问题:Python Object.move_left方法的具体用法?Python Object.move_left怎么用?Python Object.move_left使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类object.Object
的用法示例。
在下文中一共展示了Object.move_left方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: move_left
# 需要导入模块: from object import Object [as 别名]
# 或者: from object.Object import move_left [as 别名]
def move_left(self):
Object.move_left(self, self.movement_speed)
self.tile_position.move_left(self.movement_speed)
self.arena.physics.resolve_player_collision(self, Direction.LEFT)
self.current_face_direction = Direction.LEFT
self.player_left_sprite.play()
示例2: test_move_left
# 需要导入模块: from object import Object [as 别名]
# 或者: from object.Object import move_left [as 别名]
def test_move_left(self):
object = Object((100, 100), 43, 33)
object.move_left(5)
self.assertEqual(object.get_x(), 95)
示例3: Player
# 需要导入模块: from object import Object [as 别名]
# 或者: from object.Object import move_left [as 别名]
class Player(Object):
def __init__(self, position, arena, id=1):
Object.__init__(
self,
position,
PLAYER_RECTANGLE_WIDTH,
PLAYER_RECTANGLE_HEIGHT)
self.bomb_capacity = 2
self.placed_bomb = 0
self.bomb_range = 3
self.movement_speed = 3
self.current_face_direction = Direction.DOWN
self.state = PlayerState.ALIVE
self.id = id
self.arena = arena
self.player_down_sprite = create_player_down(self.id)
self.player_up_sprite = create_player_up(self.id)
self.player_left_sprite = create_player_left(self.id)
self.player_right_sprite = create_player_right(self.id)
self.player_die_sprite = create_player_die(self.id)
self.sprite_conductor = PygConductor(
self.player_down_sprite,
self.player_up_sprite,
self.player_left_sprite,
self.player_right_sprite)
self.sprite_conductor.pause()
self.bombs = list()
self.tile_position = Object(
(position[0] + TILE_OFFSET_X, position[1] + TILE_OFFSET_Y),
PLAYER_RECTANGLE_WIDTH,
PLAYER_RECTANGLE_WIDTH)
def set_player_tile_position(self, position):
self.tile_position.set_position(position)
self.set_position(
(position[0] - TILE_OFFSET_X, position[1] - TILE_OFFSET_Y))
def set_player_position(self, position):
self.set_position(position)
self.tile_position.set_position(
(position[0] + TILE_OFFSET_X, position[1] * TILE_OFFSET_Y))
def get_player_tile(self):
return self.tile_position
def move_up(self):
Object.move_up(self, self.movement_speed)
self.tile_position.move_up(self.movement_speed)
self.arena.physics.resolve_player_collision(self, Direction.UP)
self.current_face_direction = Direction.UP
self.player_up_sprite.play()
def move_down(self):
Object.move_down(self, self.movement_speed)
self.tile_position.move_down(self.movement_speed)
self.arena.physics.resolve_player_collision(self, Direction.DOWN)
self.current_face_direction = Direction.DOWN
self.player_down_sprite.play()
def move_left(self):
Object.move_left(self, self.movement_speed)
self.tile_position.move_left(self.movement_speed)
self.arena.physics.resolve_player_collision(self, Direction.LEFT)
self.current_face_direction = Direction.LEFT
self.player_left_sprite.play()
def move_right(self):
Object.move_right(self, self.movement_speed)
self.tile_position.move_right(self.movement_speed)
self.arena.physics.resolve_player_collision(self, Direction.RIGHT)
self.current_face_direction = Direction.RIGHT
self.player_right_sprite.play()
def is_alive(self):
return self.state is PlayerState.ALIVE
def current_state(self):
return self.state
def die(self):
if self.state is not PlayerState.DYING \
and self.state is not PlayerState.DEAD:
self.state = PlayerState.DYING
self.player_die_sprite.play()
#.........这里部分代码省略.........