public void CollisionTEST() { {//TEST 1 BOX A, B; A = new BOX(); B = new BOX(); A.Size = new Size(10, 10); A.TopLeft = new Point(0, 0); B.Size = new Size(10, 10); B.TopLeft = new Point(5, 5); bool result = Physics_Functions.Intersects(A, B); Assert.AreEqual(result, true); } {//TEST 2 BOX A, B; A = new BOX(); B = new BOX(); A.Size = new Size(10, 10); A.TopLeft = new Point(0, 0); B.Size = new Size(10, 10); B.TopLeft = new Point(15, 15); bool result = Physics_Functions.Intersects(A, B); Assert.AreEqual(result, false); } }
/// <summary> /// Deterimes is two BOX objects intersects with each other. /// Assumes Quadrant 4 /// </summary> public static bool Intersects(BOX A, BOX B) { if ((B.TopLeft.X <= A.TopLeft.X + A.Size.Width && B.TopLeft.X > A.TopLeft.X) && (B.TopLeft.Y <= A.TopLeft.Y + A.Size.Height && B.TopLeft.X > A.TopLeft.X)) { return(true); } return(false); }