+ 3

[Solved] Q. Please help in collision or overlapping figure canvas detector.

I have two rectangles. Both are constantly moving. I need to give a alert as soon as they both touch each other.

4th Dec 2021, 10:03 AM
Shobhit :)
Shobhit :) - avatar
3 ответов
+ 3
E_Y7-2_D REY MANTECAS I've mentioned it in the question. Their are two rectangles which are constantly moving.
4th Dec 2021, 10:06 AM
Shobhit :)
Shobhit :) - avatar
+ 2
Hint: //Two rectangle collision detection function rectscollision(rectA, rectB) { return !(rectA.x + rectA.width < rectB.x || rectB.x + rectB.width < rectA.x || rectA.y + rectA.height < rectB.y || rectB.y + rectB.height < rectA.y); }; For more please save your code on Sololearn playground and link here.
4th Dec 2021, 11:28 AM
JaScript
JaScript - avatar
+ 2
If(rectA.x > rectB.x && rectA.x < rectB.x + rectB.width{ If(rectA.y > rectBy. && rectA.y < rectB.x + rectB.height){ Collision } } If(rectA.x + rectA.width > rectB.x && rectA.x < rectB.x + rectB.width{ If(rectA.y> rectBy. && rectA.y < rectB.x + rectB.height){ Collision } } If(rectA.x > rectB.x && rectA.x < rectB.x + rectB.width{ If(rectA.y + rectA.height> rectBy. && rectA.y < rectB.x + rectB.height){ Collision } } If(rectA.x + rectA.width> rectB.x && rectA.x < rectB.x + rectB.width{ If(rectA.y + rectA.height> rectBy. && rectA.y < rectB.x + rectB.height){ Collision } This should work }
4th Dec 2021, 12:28 PM
E_Y7-2_D REY MANTECAS
E_Y7-2_D REY MANTECAS - avatar