Cauldron2D.Minimap (Cauldron2D v0.1.3)

Copy Markdown View Source

The whole map in a few rows of braille: walls in one colour, marks — players, bases, goals — over them, each a dot or a two-by-two.

Cauldron2D.Minimap.rows(
  size: {width, height},
  solid?: &MyGame.wall?/1,
  cells: {30, 12},
  marks: [{me.pos, {255, 220, 0}, 2}, {enemy.pos, {255, 90, 90}, 2}],
  key: {:my_game, map_name}
)

Each row is a list of {text, colour} runs to lay side by side, in the shape a hud row takes. A braille cell holds two columns and four rows of the map scaled to fit. Where marks meet, the earlier in the list shows.

Options

  • :size{width, height} of the map in tiles. Required
  • :solid? — a function from a tile to whether it is drawn as wall. Required
  • :cells{columns, rows} of the minimap. Required
  • :marks[{{x, y}, colour, 1 | 2}] in tiles. Default []

  • :wall, :empty — the colours of walls and of cells with nothing. Defaults {70, 100, 230} and {40, 40, 60}
  • :key — under which the scaled walls and the drawn cells are kept for later calls with the same cells and colours, in :persistent_term, so a call draws only the cells its marks touch. Default: none, drawn whole every call

Summary

Functions

The minimap as rows of runs; see the module documentation for the options.

Types

mark()

@type mark() :: {{number(), number()}, rgb(), 1 | 2}

rgb()

@type rgb() :: {byte(), byte(), byte()}

run()

@type run() :: {String.t(), rgb()}

Functions

rows(opts)

@spec rows(keyword()) :: [[run()]]

The minimap as rows of runs; see the module documentation for the options.