API Reference › Types › IVec2
type

IVec2

IVec2

IVec2 is an integer 2D vector: two whole-number int components, x and y, packed into a single value that is copied by value and never heap-allocates. It is the natural type for tile and grid coordinates, cell offsets, and integer sizes — anywhere a fractional part would be meaningless. Build one with IVec2.make(x, y) (or IVec2.zero()), read the parts with IVec2.x / IVec2.y, and combine them with the IVec2.* math — add, sub, scale, dot, and the grid-distance IVec2.manhattan. Every operation is exact integer arithmetic, so results are bit-identical on every platform. Widen to a sub-pixel Vector with IVec2.to_vector when you need fractional math.

Example

program Demo {
  handler Step phase Update {
    var cell: IVec2 = IVec2.make(4, 7)
    cell = IVec2.add(cell, IVec2.make(1, 0))
  }
}
← All symbols