Cauldron2D.GameMaker.Instance (Cauldron2D.GameMaker v0.2.1)

Copy Markdown View Source

One instance of an object in the running game, with GameMaker's built-in instance variables under their GameMaker names, and the game's own variables in vars.

Motion is kept in both forms GameMaker exposes: hspeed and vspeed, and speed and direction (degrees, counter-clockwise from +x, with y growing downwards). put_motion/2 writes either form and recomputes the other, so they always agree.

alarms is a tuple of twelve counts, -1 for an alarm that is off. image_blend is {r, g, b}; image_alpha is 0.0–1.0. sprite_index and mask_index are sprite indices, -1 for none. room_layer is whether a GameMaker Studio 2 room placed the instance on one of its instance layers, rather than code making it.

Summary

Functions

The value of alarm number, -1 when it is off.

The instance with alarm number set to steps; -1 turns it off.

The instance with its motion set by motion: %{hspeed: h, vspeed: v} (either key alone keeps the other), %{speed: s}, %{direction: d}, or both of the last two.

The instance with its own variable name set to value.

The game's own variable name, default when it is unset.

Types

t()

@type t() :: %Cauldron2D.GameMaker.Instance{
  alarms: tuple(),
  depth: number(),
  direction: number(),
  friction: number(),
  gravity: number(),
  gravity_direction: number(),
  hspeed: number(),
  id: non_neg_integer(),
  image_alpha: number(),
  image_angle: number(),
  image_blend: {byte(), byte(), byte()},
  image_index: number(),
  image_speed: number(),
  image_xscale: number(),
  image_yscale: number(),
  mask_index: integer(),
  object: non_neg_integer(),
  persistent: boolean(),
  room_layer: boolean(),
  solid: boolean(),
  speed: number(),
  sprite_index: integer(),
  vars: map(),
  visible: boolean(),
  vspeed: number(),
  x: number(),
  xprevious: number(),
  xstart: number(),
  y: number(),
  yprevious: number(),
  ystart: number()
}

Functions

alarm(instance, number)

@spec alarm(t(), 0..11) :: integer()

The value of alarm number, -1 when it is off.

put_alarm(instance, number, steps)

@spec put_alarm(t(), 0..11, integer()) :: t()

The instance with alarm number set to steps; -1 turns it off.

put_motion(instance, motion)

@spec put_motion(t(), map()) :: t()

The instance with its motion set by motion: %{hspeed: h, vspeed: v} (either key alone keeps the other), %{speed: s}, %{direction: d}, or both of the last two.

put_var(instance, name, value)

@spec put_var(t(), term(), term()) :: t()

The instance with its own variable name set to value.

var(instance, name, default \\ nil)

@spec var(t(), term(), term()) :: term()

The game's own variable name, default when it is unset.