Description

Wall position

interface IWallPosition {
    side: EWallSide;
    x: number;
    y: number;
    above(): IPosition;
    allNears(): [IPosition, IPosition, IPosition, IPosition, IPosition, IPosition, IPosition, IPosition];
    below(): IPosition;
    clone(): IPosition;
    distance(pos, formular?): number;
    down(): IPosition;
    getPositionByActionParam(param): IPosition;
    isEquals(pos): boolean;
    isNear(pos): boolean;
    isValid(width, height): boolean;
    left(): IPosition;
    lowerLeft(): IPosition;
    lowerRight(): IPosition;
    right(): IPosition;
    topRightBottomLeft(): [IPosition, IPosition, IPosition, IPosition];
    up(): IPosition;
    upperLeft(): IPosition;
    upperLeftUpperRightLowerLeftLowerRight(): [IPosition, IPosition, IPosition, IPosition];
    upperRight(): IPosition;
    x1xh1ywy(width, height): [IPosition, IPosition, IPosition, IPosition];
}

Hierarchy

Implemented by

Properties

side: EWallSide

Description

Wall side

x: number

Description

X position

y: number

Description

Y position

Methods

  • Parameters

    • pos: Position

      Position to calculate distance

    • formular: "mahata" | "euclid" = 'mahata'

      Formular to calculate distance (mahata, euclid)

    Returns number

    Distance between two positions

    Description

    Get distance between two positions

    Example

    const pos1 = new Position(1, 1);
    const pos2 = new Position(1, 2);
    const distance = pos1.distance(pos2);
    console.log(distance); // | 1 - 1 | + | 2 - 1 | = 1

    Example

    const pos1 = new Position(1, 1);
    const pos2 = new Position(1, 2);
    const distance = pos1.distance(pos2, 'euclid');
    console.log(distance); // sqrt((1 - 1) ^ 2 + (2 - 1) ^ 2) = 1
  • Parameters

    Returns boolean

    Whether the position is equal

    Description

    Check if the position is equal

    Example

    const pos1 = new Position(1, 1);
    const pos2 = new Position(1, 1);
    const isEqual = pos1.equals(pos2)
    console.log(isEqual) // true
  • Parameters

    Returns boolean

    Whether the position is near

    Description

    Check if the position is near

    Example

    const pos1 = new Position(1, 1);
    const pos2 = new Position(1, 2);
    const isNear = pos1.isNear(pos2)
    console.log(isNear) // true

    Example

    const pos1 = new Position(1, 1);
    const pos2 = new Position(1, 3);
    const isNear = pos1.isNear(pos2)
    console.log(isNear) // false
  • Parameters

    • width: number

      The width of the map

    • height: number

      The height of the map

    Returns boolean

    Whether the position is valid

    Description

    Check if the position is valid

    Example

    const pos = new Position(1, 1);
    const isValid = pos.isValid(10, 10);
    console.log(isValid); // true

    Example

    const pos = new Position(-1, 1);
    const isValid = pos.isValid(10, 10);
    console.log(isValid); // false

Generated using TypeDoc