ElixirDoom.Graphics (elixir_doom v0.1.0)

Copy Markdown View Source

Doom's pictures read out of a WAD into one Cauldron2D.Sectors.Pictures set: the composed wall textures, the floor flats, every patch — sprites, the status bar, the weapons — and the palettes and light tables to draw them with.

graphics = ElixirDoom.Graphics.load(wad)
ElixirDoom.Graphics.wall(graphics, "STARTAN3")
ElixirDoom.Graphics.sprite(graphics, "TROO", 0, 3)

Pictures are named {:wall, name}, {:flat, name} and {:patch, name} in the set. palettes holds the WAD's fourteen 768-byte palettes in order: 0 normal, 1..8 hurt, 9..12 picking up, 13 the radiation suit.

Summary

Functions

The picture id of flat name, or nil.

Read every picture in wad. native: false keeps the pictures in Elixir.

Palette index of the fourteen.

The picture id of patch name, or nil.

A patch's %{left:, top:, width:, height:}.

The picture of sprite name at frame (0 for A) seen from rotation (0 for the front, counting round anticlockwise in eighths): {picture_id, flip?, lump}, or nil where the WAD lacks it.

The picture id of wall texture name, or nil for "-" or an unknown name.

Types

t()

@type t() :: %ElixirDoom.Graphics{
  flats: [String.t()],
  palettes: tuple(),
  patches: %{
    required(String.t()) => %{
      left: integer(),
      top: integer(),
      width: pos_integer(),
      height: pos_integer()
    }
  },
  pictures: Cauldron2D.Sectors.Pictures.t(),
  sprites: %{required(String.t()) => %{required(non_neg_integer()) => tuple()}},
  textures: [String.t()]
}

Functions

flat(graphics, name)

@spec flat(t(), String.t()) :: non_neg_integer() | nil

The picture id of flat name, or nil.

load(wad, opts \\ [])

@spec load(ElixirDoom.Wad.t(), keyword()) :: t()

Read every picture in wad. native: false keeps the pictures in Elixir.

palette(graphics, index)

@spec palette(t(), 0..13) :: binary()

Palette index of the fourteen.

patch(graphics, name)

@spec patch(t(), String.t()) :: non_neg_integer() | nil

The picture id of patch name, or nil.

patch_info(graphics, name)

@spec patch_info(t(), String.t()) :: map() | nil

A patch's %{left:, top:, width:, height:}.

sprite(graphics, name, frame, rotation)

@spec sprite(t(), String.t(), non_neg_integer(), 0..7) ::
  {non_neg_integer(), boolean(), String.t()} | nil

The picture of sprite name at frame (0 for A) seen from rotation (0 for the front, counting round anticlockwise in eighths): {picture_id, flip?, lump}, or nil where the WAD lacks it.

wall(graphics, name)

@spec wall(t(), String.t()) :: non_neg_integer() | nil

The picture id of wall texture name, or nil for "-" or an unknown name.