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.

floor(self: Vector2) Vector2

Returns a Vector2 with x, y floored.

rotateClockwise(self: Vector2) The: Vector2

Rotates the vector clockwise.

Returns:

The (Vector2) – rotated vector.

hash(self: Vector2) hash: number
staticmethod _hash(x: integer, y: integer) integer
staticmethod unhash(hash: any) Vector2
staticmethod _unhash(hash: number) number, integer
distance(self: Vector2, vec: Vector2) distance: number

Euclidian distance from another point.

distanceManhattan(self: Vector2, vec: Vector2) distance: number

Manhattan distance from another point.

distanceChebyshev(self: Vector2, vec: Vector2) distance: number

Chebyshev distance from another point.

lerp(self: Vector2, vec: Vector2, t: number) Vector2

Linearly interpolates between two vectors.

Parameters:
  • vec (Vector2) – The ending vector (B).

  • t (number) – The interpolation factor (0 <= t <= 1).

Returns:

_1 (Vector2) – The interpolated vector.

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.

compose(self: Vector2, x: number, y: number)

Overwrites the vector’s x and y components with new values. This updates the current vector to match the provided x and y values.

Parameters:
  • x (number) – The new x component to set.

  • y (number) – The new y component to set.

ZERO: Vector2

The statiz ZERO vector.

UP: Vector2

The static UP vector.

RIGHT: Vector2

The static RIGHT vector.

DOWN: Vector2

The static DOWN vector.

LEFT: Vector2

The static LEFT vector.

UP_RIGHT: Vector2

The static UP_RIGHT vector.

UP_LEFT: Vector2

The static UP_LEFT vector.

DOWN_RIGHT: Vector2

The static DOWN_RIGHT vector.

DOWN_LEFT: Vector2

The static DOWN_LEFT vector.

neighborhood8: Vector2[]
neighborhood4: Vector2[]