Pre-release
Adventure.js Docs Downloads
Score: 0 Moves: 0
//getHorizontalDistance.js
/*global adventurejs A*/

/**
 * Calculate the distance between two x/z points.
 * @method adventurejs#getHorizontalDistance
 * @memberOf adventurejs
 * @param {Object} point1
 * @param {Object} point2
 * @returns {Float}
 */
adventurejs.getHorizontalDistance = function Adventurejs_getHorizontalDistance(
  point1,
  point2
) {
  const deltaX = point2.x - point1.x;
  const deltaZ = point2.z - point1.z;

  return Math.sqrt(deltaX * deltaX + deltaZ * deltaZ);
};