Description

(>= 1.3.0) Test tiles passable in an area. The array must contain only the value 0 or 1. Useful to know the movement of an entity as a part in a game of chess

  • 0 : passable
  • 1 : not passable

Returns the columns and rows in grid passable

Usage

Parameters

  • row {Integer}

    Start position (row)

  • col {Integer}

    Start position (col)

  • distance {Integer}

    Maximum search distance (number of tiles)

  • array_exception {Array} optional

    (optional) Two-dimensional array with the positions not to test : [[x0, y0], [x1, y1], ...]

Returns

Array

Example

In ready method

var matrix = [
    [0, 0, 0, 1, 0],
    [1, 0, 0, 0, 1],
    [0, 0, 1, 0, 0],
];

var grid = Class.New("Grid", [matrix]);
grid.passableCell(0, 0, 2);

// returns : [[0, 1], [0, 2], [1, 1], [0, 0]]

Discussion