Cell

Unsigned coordinate system for tiles location.

Members

Type Member Description
unsigned x Horizontal cell coordinate
unsigned y Vertical cell coordinate

Constructors

Args
new ()
new (u32 x, u32 y)

Functions

Type Function Args
Cell left ()
Cell right ()
Cell up ()
Cell down ()
Vec2 coords ()

Descriptions

Cell left()

Return a Cell with the coordinates of the adjacent left position. Cell(x, y) will become Cell(x-1, y) if x > 0, else Cell(0, y).

Cell right()

Return a Cell with the coordinates of the adjacent right position. Cell(x, y) will become Cell(x+1, y).

Cell up()

Return a Cell with the coordinates of the adjacent top position. Cell(x, y) will become Cell(x, y-1) if y > 0, else Cell(x, 0).

Cell down()

Return a Cell with the coordinates of the adjacent bottom position. Cell(x, y) will become Cell(x, y+1).

Vec2 coords()

Return a Vec2 with the world coordinates of the Cell. Will Cell(x, y) you’ll get Vec2(x16.0, y16.0)

Examples

-- Constructors
local c1 = Cell:new()
local c2 = Cell:new(4, 8)

-- Members
c1.x = 8
c1.y = 2

-- Conversion to Vec2
local pos = c2:down():coords()