v2026.6.0
All Bundles
Bundle SDL2-based game framework with sprite management, collision detection, tilemaps, camera, and scene graph. Builds on sdl2.obl for structured 2D game development. Compile with -lib sdl2.

Vector2

2D floating-point vector

Operations

Add #

Adds to current vector

method : public : Add(rhs:Vector2) ~ Nil

Parameters

NameTypeDescription
rhsVector2vector to add

Add # function

Add two vectors

function : Add(lhs:Vector2, rhs:Vector2) ~ Vector2

Parameters

NameTypeDescription
lhsVector2left vector
rhsVector2right vector

Return

TypeDescription
Vector2new vector

AddX #

Increments the current x-position

method : public : AddX(rhs:Vector2) ~ Nil

Parameters

NameTypeDescription
rhsVector2increment to the current x-position

AddX #

Increments the current x-position

method : public : AddX(x:Int) ~ Nil

Parameters

NameTypeDescription
xIntincrement to the current x-position

AddY #

Increments the current y-position

method : public : AddY(rhs:Vector2) ~ Nil

Parameters

NameTypeDescription
rhsVector2increment to the current y-position

AddY #

Increments the current y-position

method : public : AddY(y:Int) ~ Nil

Parameters

NameTypeDescription
yIntincrement to the current y-position

Div #

Divides current vector

method : public : Div(rhs:Vector2) ~ Nil

Parameters

NameTypeDescription
rhsVector2vector to divide

Div #

Divides current vector

method : public : Div(v:Float) ~ Nil

Parameters

NameTypeDescription
vFloatv to divide by

Div # function

Divides two vectors

function : Div(lhs:Vector2, rhs:Vector2) ~ Vector2

Parameters

NameTypeDescription
lhsVector2left vector
rhsVector2right vector

Return

TypeDescription
Vector2new vector

Div # function

Divides a vector by a value

function : Div(rhs:Vector2, v:Float) ~ Vector2

Parameters

NameTypeDescription
rhsVector2vector
vFloatvalue to divides by

Return

TypeDescription
Vector2new vector

DivX #

Divides the current x-position

method : public : DivX(rhs:Vector2) ~ Nil

Parameters

NameTypeDescription
rhsVector2value to divide by the current x-position

DivX #

Divides the current x-position

method : public : DivX(x:Int) ~ Nil

Parameters

NameTypeDescription
xIntvalue to divide by the current x-position

DivX # function

Divides x-vector component by a value

function : DivX(rhs:Vector2, v:Float) ~ Vector2

Parameters

NameTypeDescription
rhsVector2vector
vFloatvalue to multiple by

Return

TypeDescription
Vector2new vector

DivY #

Divides the current y-position

method : public : DivY(rhs:Vector2) ~ Nil

Parameters

NameTypeDescription
rhsVector2value to divide by the current y-position

DivY #

Divides the current y-position

method : public : DivY(y:Int) ~ Nil

Parameters

NameTypeDescription
yIntvalue to divide by the current y-position

DivY # function

Divides y-vector component by a value

function : DivY(rhs:Vector2, v:Float) ~ Vector2

Parameters

NameTypeDescription
rhsVector2vector
vFloatvalue to divide by

Return

TypeDescription
Vector2new vector

Dot # function

Calculates the dot product

function : Dot(lhs:Vector2, rhs:Vector2) ~ Float

Parameters

NameTypeDescription
lhsVector2left vector
rhsVector2right vector

Return

TypeDescription
Floatdot product

GetX #

Gets the x-position

method : public : GetX() ~ Float

Return

TypeDescription
Floatx-position

GetY #

Gets the y-position

method : public : GetY() ~ Float

Return

TypeDescription
Floaty-position

Limit #

Sets vector limit

method : public : Limit(v:Float) ~ Nil

Parameters

NameTypeDescription
vFloatlimit

Limit #

Sets vector limit

method : public : Limit(x:Float, y:Float) ~ Nil

Parameters

NameTypeDescription
xFloatx-limit
yFloaty-limit

Magnitude #

Calculates the magnitude

method : public : Magnitude() ~ Float

Return

TypeDescription
Floatmagnitude

MagnitudeSquared #

Calculates the magnitude squared

method : public : MagnitudeSquared() ~ Float

Return

TypeDescription
Floatmagnitude squared

Mul #

Multiples current vector

method : public : Mul(rhs:Vector2) ~ Nil

Parameters

NameTypeDescription
rhsVector2vector to multiply

Mul #

Multiples current vector

method : public : Mul(v:Float) ~ Nil

Parameters

NameTypeDescription
vFloatv to multiply by

Mul # function

Multiplies two vectors

function : Mul(lhs:Vector2, rhs:Vector2) ~ Vector2

Parameters

NameTypeDescription
lhsVector2left vector
rhsVector2right vector

Return

TypeDescription
Vector2new vector

Mul # function

Multiplies a vector by a value

function : Mul(rhs:Vector2, v:Float) ~ Vector2

Parameters

NameTypeDescription
rhsVector2vector
vFloatvalue to multiple by

Return

TypeDescription
Vector2new vector

MulX #

Multiplies the current x-position

method : public : MulX(rhs:Vector2) ~ Nil

Parameters

NameTypeDescription
rhsVector2value to multiply to the current x-position

MulX #

Multiplies the current x-position

method : public : MulX(x:Int) ~ Nil

Parameters

NameTypeDescription
xIntvalue to multiply to the current x-position

MulX # function

Multiplies x-vector component by a value

function : MulX(rhs:Vector2, v:Float) ~ Vector2

Parameters

NameTypeDescription
rhsVector2vector
vFloatvalue to multiple by

Return

TypeDescription
Vector2new vector

MulY #

Multiplies the current y-position

method : public : MulY(rhs:Vector2) ~ Nil

Parameters

NameTypeDescription
rhsVector2value to multiply to the current y-position

MulY #

Multiplies the current y-position

method : public : MulY(y:Int) ~ Nil

Parameters

NameTypeDescription
yIntvalue to multiply to the current y-position

MulY # function

Multiplies y-vector component by a value

function : MulY(rhs:Vector2, v:Float) ~ Vector2

Parameters

NameTypeDescription
rhsVector2vector
vFloatvalue to multiply by

Return

TypeDescription
Vector2new vector

New # constructor

Creates a new vector

New()

New # constructor

Creates a new vector

New(x:Float, y:Float)

Parameters

NameTypeDescription
xFloatx-position
yFloaty-position

Normalize #

Normalizes a unit vector

method : public : Normalize() ~ Nil

Set #

Sets the x and y positions

method : public : Set(x:Float, y:Float) ~ Nil

Parameters

NameTypeDescription
xFloatx-position
yFloaty-position

SetX #

Sets the x-position

method : public : SetX(x:Float) ~ Nil

Parameters

NameTypeDescription
xFloatx-position

SetY #

Sets the y-position

method : public : SetY(y:Float) ~ Nil

Parameters

NameTypeDescription
yFloaty-position

Sub #

Subtracts from current vector

method : public : Sub(rhs:Vector2) ~ Nil

Parameters

NameTypeDescription
rhsVector2vector to subtract

Sub # function

Subtract two vectors

function : Sub(lhs:Vector2, rhs:Vector2) ~ Vector2

Parameters

NameTypeDescription
lhsVector2left vector
rhsVector2right vector

Return

TypeDescription
Vector2new vector

SubX #

Decrements the current x-position

method : public : SubX(rhs:Vector2) ~ Nil

Parameters

NameTypeDescription
rhsVector2decrements to the current x-position

SubX #

Decrements the current x-position

method : public : SubX(x:Int) ~ Nil

Parameters

NameTypeDescription
xIntdecrements to the current x-position

SubY #

Decrements the current y-position

method : public : SubY(rhs:Vector2) ~ Nil

Parameters

NameTypeDescription
rhsVector2decrements to the current y-position

SubY #

Decrements the current y-position

method : public : SubY(y:Int) ~ Nil

Parameters

NameTypeDescription
yIntdecrements to the current y-position

ToString #

String representation of vector

method : public : ToString() ~ String

Return

TypeDescription
Stringstring representation

Zero #

Sets vector to zero

method : public : Zero() ~ Nil