GamesEngine.Grid.Coordinate (games_engine v0.2.0)

Coordinate Component - represents a square within a grid

Currently also provides functions for handling coordinate transformations.

Summary

Functions

Converts a coordinate's linear index to row/col subscript

Creates a new %Coordinate{} struct

Converts a coordinate's row/col subscript into a linear index

Types

@type t() :: %GamesEngine.Grid.Coordinate{
  attributes: term(),
  col: term(),
  row: term()
}

Functions

Link to this function

ind2sub(ind, rows, cols)

Converts a coordinate's linear index to row/col subscript

0360,00,10,2
147-->1,01,11,2
2582,02,12,2
@spec new({non_neg_integer(), non_neg_integer()}) :: t()

Creates a new %Coordinate{} struct

Link to this function

new(arg, attributes)

@spec new(
  {non_neg_integer(), non_neg_integer()},
  map()
) :: t()
Link to this function

sub2ind(arg, rows, cols)

Converts a coordinate's row/col subscript into a linear index

0,00,10,2036
1,01,11,2-->147
2,02,12,2258