Menu

Path

Hugh Greene

A path is a resource in ENIGMA which allows instances to be moved
along a straight or a curved line. Paths can be made in LGM path editor
and stored in the executable itself or be created at runtime.

Uses

Paths are very useful for smooth movement and animations. They are also
used in motion planning. Instances can be
assigned to paths and it will move along it with the given speed and
direction.

Functions

Creating and modifying paths:

  • - Adds an empty path and returns its id which is then used in other
    functions.

  • - Destroys the path with the given path id and frees the memory
    associated with it.

  • - Duplicates the path with the given path id and returns the id of
    the copy.

  • - Copies the path from path source (srcid) to path id.

  • - The same as path_copy and is used just for compatibility.

  • - Appends the path with given path id to path ind.

  • - Adds a point to the path with the given path id, at position
    (x,y) and with the given speed factor. Remember that a factor of 100
    corresponds to the actual speed. Lower values mean slowing down and
    higher mean speeding up.

  • - Inserts a point in the path with the given path id before point
    n, at position (x,y) and with the given speed factor.

  • - Changes the point n in the path with the given path id to
    position (x,y) and the given speed factor.

  • - Deletes the point n in the path with the given path id.

  • - Clears all the points in the path, turning it into an empty path.

  • - Reverses the path.

  • - Mirrors the path horizontally (with respect to its center).

  • - Flips the path vertically (with respect to its center).

  • - Rotates the path counter clockwise over angle degrees (around its
    center).

  • - Scales the path with the given factors (from its center).

  • - Shifts the path over the given amount.

  • - Sets the type of the path with the given path id (0=straight,
    1=smooth).

  • - Sets whether the path must be closed (true) or open (false).

  • - Sets the precision with which the smooth path is calculated
    (should lie between 1 and 8).

Getting path information:

  • - Returns whether a path with the given path id exists.

  • - Returns the length of the path with the given path id.

  • - Returns the type the path with the given path id (0=straight,
    1=smooth).

  • - Returns whether the path is closed (true) or not (false).

  • - Returns the precision used for creating smoothed paths.

  • - Returns the x position of the paths center (the point around
    which path is scaled, rotated, mirrored and flipped).

  • - Returns the y position of the paths center (the point around
    which path is scaled, rotated, mirrored and flipped).

  • - Returns the number of defining points for the path.

  • - Returns the x-coordinate of the n'th defining point for the path.
    0 is the first point.

  • - Returns the y-coordinate of the n'th defining point for the path.
    0 is the first point.

  • - Returns the speed factor for the n'th defining point for the
    path. 0 is the first point.

  • - Returns the length for the n'th defining point for the path. 0 is
    the first point. This is mostly for debugging purposes. The returned
    value is in pixels.

  • - Returns the x-coordinate at position pos for the path. pos must
    lie between 0 and 1.

  • - Returns the y-coordinate at position pos for the path. pos must
    lie between 0 and 1.

  • - Returns the speed factor at position pos for the path. pos must
    lie between 0 and 1.

  • - Returns the path direction at position pos for the path. pos must
    lie between 0 and 1. It is always pointing from smaller pos to
    larger. So if the desired direction is reversed, then the 180 must
    be subtracted from the returned value.

Other:

  • - Draws the indicated path in the room with its start at position
    (x,y). If absolute is true the path is drawn at the position where
    it was defined and the values of x and y are ignored. The function
    is mostly used for debugging, but can also be used for some nice
    effects (or showing where the instance is moving in an RTS for
    example). It uses current drawing color and alpha. Line pattern can
    be added by using
    draw_set_line_pattern.

Related

Wiki: GM_format
Wiki: Paths
Wiki: Resource_tree

MongoDB Logo MongoDB