Cauldron2D.Parallax.Scatter (Cauldron2D v0.2.2)

Copy Markdown View Source

A cell function that places art by hashing the tile's own coordinate.

Cauldron2D.Parallax.Scatter.cells(seed: 7, density: 0.08, arts: [:pine, {:boulder, 1}])

The function answers for any coordinate, keeps no state, and gives the same answer every time it is asked and on every node, so a scattered layer never has to be sent anywhere.

Summary

Functions

Build the cell function.

The same hash the cell function draws from, for a caller placing its own things.

Types

art()

@type art() :: term()

cell()

@type cell() :: :void | {art(), [art()], nil}

Functions

cells(opts)

@spec cells(keyword()) :: ({integer(), integer()} -> cell())

Build the cell function.

Options

  • :arts — what to place, as [art | {art, weight}], required and not empty. A bare art counts as weight 1

  • :seed — this layer's own seed. Default 0
  • :density — the fraction of tiles holding art, 0.0..1.0. Default 0.05
  • :rows — a range of tile rows art may stand in. Default every row

draw_at(seed, x, y)

@spec draw_at(integer(), integer(), integer()) :: non_neg_integer()

The same hash the cell function draws from, for a caller placing its own things.