Child class

Property

new Vec(x, y)

Creates a new vector. Can also be done with constructors.V.

Parameters

Name Type Optional Description

x

 

 

The x component

y

 

 

The y component

Returns

Class

Property

size

Gets the size of the vector

Returns

number 

Methods

add(other) → Vec

Add another vector to this one

Parameter

Name Type Optional Description

other

Vec

 

The other vector

Returns

Vec 

A new vector

adj() → Array of Vec

Gets a list of the four adjacent vectors to this one

Returns

Array of Vec 

clone() → Vec

Clones the vector

Returns

Vec 

div(factor) → Vec

Divides this vector by factor

Parameter

Name Type Optional Description

factor

number

 

The factor to divide by

Returns

Vec 

A new vector

down() → Vec

Moves the vector down by 1 unit using Vec.downn

Returns

Vec 

The new vector

downn(n) → Vec

Moves the vector down by n units (increases y), in place.

Parameter

Name Type Optional Description

n

number

 

The number of units to move

Returns

Vec 

The new vector

left() → Vec

Moves the vector left by 1 unit using Vec.leftn

Returns

Vec 

The new vector

leftn(n) → Vec

Moves the vector left by n units (decreases x), in place.

Parameter

Name Type Optional Description

n

number

 

The number of units to move

Returns

Vec 

The new vector

mul(factor) → Vec

Multiplies this vector by factor

Parameter

Name Type Optional Description

factor

number

 

The factor to multiply by

Returns

Vec 

A new vector

on(grid) → T

Gets the cell at this vector on grid

Parameter

Name Type Optional Description

grid

Array of Array of T

 

The grid to get the cell from

Returns

T 

Moves the vector right by 1 unit using Vec.rightn

Returns

Vec 

The new vector

rightn(n) → Vec

Moves the vector right by n units (increases x), in place.

Parameter

Name Type Optional Description

n

number

 

The number of units to move

Returns

Vec 

The new vector

sub(other) → Vec

Subtract another vector from this one

Parameter

Name Type Optional Description

other

Vec

 

The other vector

Returns

Vec 

A new vector

up() → Vec

Moves the vector up by 1 unit using Vec.upn

Returns

Vec 

The new vector

upn(n) → Vec

Moves the vector up by n units (decreases y), in place.

Parameter

Name Type Optional Description

n

number

 

The number of units to move

Returns

Vec 

The new vector