예제 #1
0
파일: Collider.cs 프로젝트: Gnoll/XNAPunk
        private static bool CollideRectCirc(RectangleCollider a, CircleCollider b)
        {
            if (a.IntersectsPoint(b.GetCenter()))
                return true;

            //Check the circle against the four edges of the rectangle
            Vector2 pA = a.GetTopLeft();
            Vector2 pB = a.GetTopRight();
            Vector2 pC = a.GetBottomRight();
            Vector2 pD = a.GetBottomLeft();
            if (b.IntersectsLine(pA, pB, 0) || b.IntersectsLine(pB, pC, 0) || b.IntersectsLine(pC, pD, 0) || b.IntersectsLine(pD, pA, 0))
                return true;

            return false;
        }
예제 #2
0
파일: Collider.cs 프로젝트: Gnoll/XNAPunk
        private static bool CollideRectRect(RectangleCollider a, RectangleCollider b)
        {
            if (a.GetBottom() < b.GetTop())
                return false;

            if (a.GetTop() > b.GetBottom())
                return false;

            if (a.GetRight() < b.GetLeft())
                return false;

            if (a.GetLeft() > b.GetRight())
                return false;

            return true;
        }