-
class Vector2 :
Object
¶ -
x:
number
¶ The x component of the vector.
-
y:
number
¶ The y component of the vector.
-
__new(self:
Vector2
, x:number
, y:number
)¶ Constructor for Vector2 accepts two numbers, x and y. Both default to zero.
- Parameters:
x (
number
) – The x component of the vector.y (
number
) – The y component of the vector.
-
copy(self:
Vector2
, out:any
)Vector2
¶ Returns a copy of the vector.
- Returns:
_1 (
Vector2
) – A copy of the vector.
-
length(self:
Vector2
)number
¶ Returns the length of the vector.
- Returns:
_1 (
number
) – The length of the vector.
-
rotateClockwise(self:
Vector2
) The:Vector2
¶ Rotates the vector clockwise.
- Returns:
The (
Vector2
) – rotated vector.
-
staticmethod _hash(x:
integer
, y:integer
)integer
¶
-
staticmethod _unhash(hash:
number
)number
,integer
¶
-
distanceManhattan(self:
Vector2
, vec:Vector2
) distance:number
¶ Manhattan distance from another point.
-
distanceChebyshev(self:
Vector2
, vec:Vector2
) distance:number
¶ Chebyshev distance from another point.
-
getRange(self:
Vector2
, vec:Vector2
, type?: "4way" | "8way" | "chebyshev" | "euclidean" | "manhattan")number
¶ Gets the range, a ceil’d integer representing the number of tiles away the other vector is.
-
decompose(self:
Vector2
) x:number
, y:number
¶ Returns the x and y components of the vector separately. This allows you to access the individual components of the vector as separate values.
- Returns:
x (
number
) – The x component of the vector.y (
number
) – The y component of the vector.
-
x: