def walk_animation(self): """Animation for the player walking.""" # This animation is hardcoded for 4 frames and 16x24 map tiles d = self.direction dpos = Direction.dir_update(d) for frame in range(4): if d < len(self.frames) and frame < len(self.frames[d]): self.image = self.frames[d][frame] else: self.image = self.frames[0][0] yield None self.move(Position(3 * dpos.x, 2 * dpos.y)) yield None self.move(Position(3 * dpos.x, 2 * dpos.y))
def dir_pos(self, direction): return self + Direction.dir_update(direction)