Cauldron2D.Sectors.Automap (Cauldron2D v0.2.2)

Copy Markdown View Source

A map of the level drawn from above, out of the lines the player has seen: as lines for Cauldron2D.Sectors.Frame.lines/2.

lines = Cauldron2D.Sectors.Automap.lines(map, sectors, seen, view, colours)
frame |> Frame.fill(0) |> Frame.lines(lines ++ Cauldron2D.Sectors.Automap.arrow(view, 209))

seen is the set of line indexes seen so far — the union of Cauldron2D.Sectors.View.render/5's seen over the game. A line flagged :mapped is shown whether seen or not, one flagged :hidden never. With all: true every unseen line is drawn too, in the :unseen colour.

view is %{x:, y:, angle:, scale:, center: {cx, cy}, rotate: false}: the world point at the frame's center, scale pixels to a world unit, and with rotate: true the map turned so angle points up the screen.

colours maps each kind of line to a colour index: :wall (nothing behind it, or a :secret line), :floor_step, :ceiling_step, :plain (an opening with no step, left out where there is no colour for it) and :unseen.

Summary

Functions

An arrow at the view's point, pointing along its angle, size world units long.

The map's lines as frame lines. See the moduledoc.

Where world point falls on the frame for view.

Types

view()

@type view() :: %{
  :x => number(),
  :y => number(),
  :angle => number(),
  :scale => number(),
  :center => {number(), number()},
  optional(:rotate) => boolean()
}

Functions

arrow(view, colour, size \\ 16.0)

@spec arrow(view(), byte(), number()) :: [
  {integer(), integer(), integer(), integer(), byte()}
]

An arrow at the view's point, pointing along its angle, size world units long.

lines(map, sectors, seen, view, colours, opts \\ [])

@spec lines(Cauldron2D.Sectors.Map.t(), tuple(), MapSet.t(), view(), map(), keyword()) ::
  [
    {integer(), integer(), integer(), integer(), byte()}
  ]

The map's lines as frame lines. See the moduledoc.

screen(view, arg)

@spec screen(view(), {number(), number()}) :: {integer(), integer()}

Where world point falls on the frame for view.