ElixirDoom.World (elixir_doom v0.1.0)

Copy Markdown View Source

One level being played: the sectors and sides as they are now, every thing in it, the players, the sector machinery at work, and the random draw everything shares.

A world is a plain value changed by pure functions; ElixirDoom.Game drives it a tic at a time. Its geometry, map, never changes; sectors and sides do, as floors move and switches flip. Things are mobjs, keyed by id; players key a player's state by their id in the game, each holding the id of the thing they move as.

Summary

Functions

How many world units one unit of audio distance is.

Add amount to total key.

Thing id, or nil once it is gone.

A world for level, its map's blockmap and sound index built.

The geometry and live sectors in the shape Cauldron2D.Sectors.Move takes.

Replace a thing, keeping the blockmap in step with where it is.

The next draw from the random table, 0..255.

The difference of two random draws, -255..255, as Doom spreads shots and turns.

Remove thing id from the world.

Sector index as it is now.

A sound heard at a thing's position, or everywhere when at is nil.

The setting key of the world's tuning.

Apply fun to thing id if it is still there.

Replace sector index with fun.(sector).

Types

t()

@type t() :: %ElixirDoom.World{
  blockmap: term(),
  busy: term(),
  events: term(),
  exit: term(),
  level: term(),
  map: term(),
  mobjs: term(),
  next_id: term(),
  noise: term(),
  players: term(),
  rnd: term(),
  sectors: term(),
  sides: term(),
  skill: term(),
  sky: term(),
  starts: term(),
  targets: term(),
  thinkers: term(),
  tic: term(),
  totals: term(),
  tuning: term(),
  used: term()
}

Functions

audio_scale()

@spec audio_scale() :: float()

How many world units one unit of audio distance is.

count(world, key, amount \\ 1)

@spec count(t(), atom(), integer()) :: t()

Add amount to total key.

mobj(world, id)

@spec mobj(t(), term()) :: map() | nil

Thing id, or nil once it is gone.

new(level, opts \\ [])

@spec new(ElixirDoom.Level.t(), keyword()) :: t()

A world for level, its map's blockmap and sound index built.

physics(world)

@spec physics(t()) :: map()

The geometry and live sectors in the shape Cauldron2D.Sectors.Move takes.

put_mobj(world, mobj)

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

Replace a thing, keeping the blockmap in step with where it is.

random(world)

@spec random(t()) :: {0..255, t()}

The next draw from the random table, 0..255.

random_spread(world)

@spec random_spread(t()) :: {integer(), t()}

The difference of two random draws, -255..255, as Doom spreads shots and turns.

remove_mobj(world, id)

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

Remove thing id from the world.

sector(world, index)

@spec sector(t(), non_neg_integer()) :: map()

Sector index as it is now.

sound(world, name, arg3)

@spec sound(t(), String.t() | nil, map() | {number(), number()} | nil) :: t()

A sound heard at a thing's position, or everywhere when at is nil.

tuning(world, key)

@spec tuning(t(), atom()) :: term()

The setting key of the world's tuning.

update_mobj(world, id, fun)

@spec update_mobj(t(), term(), (map() -> map())) :: t()

Apply fun to thing id if it is still there.

update_sector(world, index, fun)

@spec update_sector(t(), non_neg_integer(), (map() -> map())) :: t()

Replace sector index with fun.(sector).