1.10.01 - Straight movement

A straight movement follows a rectilinear trajectory. You can define the trajectory as an angle and a speed.

Methods inherited from movement

Straight movements are particular movement objects. Therefore, they inherit all methods from the type movement.

See Methods of all movement types to know these methods.

Methods of the type straight movement

The following methods are specific to straight movements.

straight_movement:get_speed()

Returns the speed of this movement.

straight_movement:set_speed(speed)

Sets the speed of this movement.

straight_movement:get_angle()

Returns the angle of the trajectory in radians.

East is 0, North is math.pi / 2, West is math.pi, South is 3 * math.pi / 2 and any intermediate value is possible.

Remarks
If you prefer a value in a 4-direction system, see movement:get_direction4().

straight_movement:set_angle(angle)

Sets the angle of the trajectory in radians.

East is 0, North is math.pi / 2, West is math.pi, South is 3 * math.pi / 2 and any intermediate value is possible. Negative values and values greater to 2 * math.pi are also accepted.

straight_movement:get_max_distance()

Returns the maximum distance of this movement.

The movement will stop when this distance is reached.

straight_movement:set_max_distance(max_distance)

Sets the maximum distance of this movement.

The movement will stop when this distance is reached.

straight_movement:is_smooth()

Returns whether this movement adjusts its trajectory when an obstacle of the map is reached. This property has no effect if the movement is not attached to a map entity or if the movement ignores obstacles.

straight_movement:set_smooth([smooth])

Sets whether this movement should adjust its trajectory when an obstacle of the map is reached. This property has no effect if the movement is not attached to a map entity or if the movement ignores obstacles.

Events inherited from movement

Straight movements are particular movement objects. Therefore, they inherit all events from the type movement.

See Events of all movement types to know these events.