src/navmesh.js
function(tile) {
    var x = tile.x;
    var y = tile.y;
    var xUp = x + 1 < xUpperBound;
    var xDown = x >= 0;
    var yUp = y + 1 < yUpperBound;
    var yDown = y >= 0;

    var adjacents = [];
    if (xUp) {
      adjacents.push({x: x + 1, y: y});
      if (yUp) {
        adjacents.push({x: x + 1, y: y + 1});
      }
      if (yDown) {
        adjacents.push({x: x + 1, y: y - 1});
      }
    }
    if (xDown) {
      adjacents.push({x: x - 1, y: y});
      if (yUp) {
        adjacents.push({x: x - 1, y: y + 1});
      }
      if (yDown) {
        adjacents.push({x: x - 1, y: y - 1});
      }
    }
    if (yUp) {
      adjacents.push({x: x, y: y + 1});
    }
    if (yDown) {
      adjacents.push({x: x, y: y - 1});
    }
    return adjacents;
  }
function(tile) {
    var x = tile.x;
    var y = tile.y;
    var xUp = x + 1 < xUpperBound;
    var xDown = x >= 0;
    var yUp = y + 1 < yUpperBound;
    var yDown = y >= 0;

    var adjacents = [];
    if (xUp) {
      adjacents.push({x: x + 1, y: y});
      if (yUp) {
        adjacents.push({x: x + 1, y: y + 1});
      }
      if (yDown) {
        adjacents.push({x: x + 1, y: y - 1});
      }
    }
    if (xDown) {
      adjacents.push({x: x - 1, y: y});
      if (yUp) {
        adjacents.push({x: x - 1, y: y + 1});
      }
      if (yDown) {
        adjacents.push({x: x - 1, y: y - 1});
      }
    }
    if (yUp) {
      adjacents.push({x: x, y: y + 1});
    }
    if (yDown) {
      adjacents.push({x: x, y: y - 1});
    }
    return adjacents;
  }
function ( tile ) { var x = tile . x ; var y = tile . y ; var xUp = x + 1 < xUpperBound ; var xDown = x >= 0 ; var yUp = y + 1 < yUpperBound ; var yDown = y >= 0 ; var adjacents = [ ] ; if ( xUp ) { adjacents . push ( { x : x + 1 , y : y } ) ; if ( yUp ) { adjacents . push ( { x : x + 1 , y : y + 1 } ) ; } if ( yDown ) { adjacents . push ( { x : x + 1 , y : y - 1 } ) ; } } if ( xDown ) { adjacents . push ( { x : x - 1 , y : y } ) ; if ( yUp ) { adjacents . push ( { x : x - 1 , y : y + 1 } ) ; } if ( yDown ) { adjacents . push ( { x : x - 1 , y : y - 1 } ) ; } } if ( yUp ) { adjacents . push ( { x : x , y : y + 1 } ) ; } if ( yDown ) { adjacents . push ( { x : x , y : y - 1 } ) ; } return adjacents ; }
Get the locations adjacent to a given tile in the map.
Get the locations adjacent to a given tile in the map .