|
@@ -1140,6 +1140,21 @@ const game = {
|
|
x <= cur.xWithAnchor + cur.width * cur.scale
|
|
x <= cur.xWithAnchor + cur.width * cur.scale
|
|
);
|
|
);
|
|
},
|
|
},
|
|
|
|
+ /**
|
|
|
|
+ * Checks if 2 images overlap
|
|
|
|
+ *
|
|
|
|
+ * @param {object} imageA image 1
|
|
|
|
+ * @param {object} imageB image 2
|
|
|
|
+ *
|
|
|
|
+ * @returns {boolean} true if there is overlap
|
|
|
|
+ */
|
|
|
|
+ isOverlap: function (imageA, imageB) {
|
|
|
|
+ const xA = imageA.x;
|
|
|
|
+ const xB = imageB.x;
|
|
|
|
+
|
|
|
|
+ // Consider it comming from both sides
|
|
|
|
+ return !(Math.abs(xA - xB) > 14);
|
|
|
|
+ },
|
|
/**
|
|
/**
|
|
* Get mouse position coordinates
|
|
* Get mouse position coordinates
|
|
*
|
|
*
|