GamesEngine.Grid (games_engine v0.2.2)

Grid component - represents a collection of Coordinates

Summary

Functions

Adds a new attributes to a %Tile{} Will not overwrite the attribute if it already exists

Creates a new %Grid{} struct Automatically populates the :coordinates attribute with a map of %Coordinate{}s based on the supplied dimensions

Populates a %Grid{} with %Tile{}s

Replaces the attributes of a tile

Updates an existing attribute of a %Tile{}

Types

@type t() :: %GamesEngine.Grid{cols: term(), rows: term(), tiles: term()}

Functions

Link to this function

add_tile_attribute(grid, ind, key, value)

@spec add_tile_attribute(t(), non_neg_integer(), atom(), any()) ::
  t() | {:error, String.t()}

Adds a new attributes to a %Tile{} Will not overwrite the attribute if it already exists

Link to this function

new(rows, cols)

@spec new(non_neg_integer(), non_neg_integer()) :: t() | {:error, String.t()}

Creates a new %Grid{} struct Automatically populates the :coordinates attribute with a map of %Coordinate{}s based on the supplied dimensions

Link to this function

populate(grid, attributes \\ %{})

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

Populates a %Grid{} with %Tile{}s

Link to this function

replace_tile_attributes(grid, ind, attributes)

@spec replace_tile_attributes(t(), non_neg_integer(), map()) ::
  t() | {:error, String.t()}

Replaces the attributes of a tile

Link to this function

update_tile_attribute(grid, ind, key, value)

@spec update_tile_attribute(t(), non_neg_integer(), atom(), any()) ::
  t() | {:error, String.t()}

Updates an existing attribute of a %Tile{}