showing results for - "js library for checking if two shapes overlap"
Valentina
07 Jan 2019
1function rectangle(x, y, w, h) {
2
3    ... existing code here ...
4
5}
6
7rectangle.prototype.intersects = function(rect) {
8    return !( rect.x           > (this.x + this.w) || 
9             (rect.x + rect.w) <  this.x           || 
10              rect.y           > (this.y + this.h) ||
11             (rect.y + rect.h) <  this.y);
12}