Cauldron2D.GameMaker.Path (Cauldron2D.GameMaker v0.2.1)

Copy Markdown View Source

A path (a PATH entry): points, each {x, y, speed} with speed a percentage of the speed the path is followed at. smooth paths curve through their points precision times between each pair; closed paths join their last point to their first.

position/2 is where a path is at a fraction of its length (path_get_x, path_get_y, path_get_speed).

Summary

Functions

{x, y, speed} at fraction at (0–1) of the path's length, as GameMaker computes it: a smooth path is first broken into the points of its curve — from its first point, the middle of each corner (the quarter-weighted mean of the midpoints and the corner) subdivided precision times while a half is longer than 4 pixels, to its last point — and the position lies along the straight lines between them. {0, 0, 0} for a path without points.

The path at at.

Types

t()

@type t() :: %Cauldron2D.GameMaker.Path{
  closed: boolean(),
  name: String.t(),
  points: [{number(), number(), number()}],
  precision: non_neg_integer(),
  smooth: boolean()
}

Functions

position(path, at)

@spec position(t(), number()) :: {number(), number(), number()}

{x, y, speed} at fraction at (0–1) of the path's length, as GameMaker computes it: a smooth path is first broken into the points of its curve — from its first point, the middle of each corner (the quarter-weighted mean of the midpoints and the corner) subdivided precision times while a half is longer than 4 pixels, to its last point — and the position lies along the straight lines between them. {0, 0, 0} for a path without points.

read(data, at)

@spec read(binary(), non_neg_integer()) :: t()

The path at at.