Cauldron2D.GameMaker.Background (Cauldron2D.GameMaker v0.2.1)

Copy Markdown View Source

A background (a BGND entry): a picture GameMaker Studio 1 rooms draw behind or in front of everything and cut tiles from, and, from GameMaker Studio 2, a tileset.

picture is the Cauldron2D.GameMaker.Region the picture comes from. A tileset also has a tiles map:

  • size — {width, height} of one tile
  • border — {x, y}, the pixels between tiles on the page
  • columns — tiles across the picture
  • count — how many tiles there are
  • frames — pictures per tile; above 1 a tile animates, one frame every frame_time microseconds, through ids, which lists each tile's frames in turn

Tile n sits at column rem(n, columns) and row div(n, columns), each cell size plus border twice, the picture starting border into the cell.

Summary

Functions

The background at at; format decides whether it carries a tileset.

Where tile id sits in the picture, as {x, y, width, height}.

Types

t()

@type t() :: %Cauldron2D.GameMaker.Background{
  name: String.t(),
  picture: Cauldron2D.GameMaker.Region.t() | nil,
  smooth: boolean(),
  tiles: tiles() | nil
}

tiles()

@type tiles() :: %{
  size: {pos_integer(), pos_integer()},
  border: {non_neg_integer(), non_neg_integer()},
  columns: pos_integer(),
  count: non_neg_integer(),
  frames: pos_integer(),
  frame_time: non_neg_integer(),
  ids: [non_neg_integer()]
}

Functions

read(data, at, regions, format)

@spec read(
  binary(),
  non_neg_integer(),
  %{required(non_neg_integer()) => Cauldron2D.GameMaker.Region.t()},
  atom()
) :: t()

The background at at; format decides whether it carries a tileset.

tile_source(background, id)

@spec tile_source(t(), non_neg_integer()) ::
  {non_neg_integer(), non_neg_integer(), pos_integer(), pos_integer()}

Where tile id sits in the picture, as {x, y, width, height}.