intersects
Version:
a simple collection of 2d collision/intersects functions, supporting points, circles, circle outlines (circumference), lines, axis-aligned boxes, and polygons (convex)
17 lines (15 loc) • 418 B
JavaScript
/**
* box-point collision
* @param {number} x1 top-left corner of box
* @param {number} y1 top-left corner of box
* @param {number} w1 width of box
* @param {number} h1 height of box
* @param {number} x2 of point
* @param {number} y2 of point
* @return {boolean}
*/
module.exports = function boxPoint(x1, y1, w1, h1, x2, y2)
{
return x2 >= x1 && x2 <= x1 + w1 && y2 >= y1 && y2 <= y1 + h1
}