All pastes #559015 Raw Edit

Circle collision XNA

public text v1 · immutable
·published 2007-06-11 16:20 UTC
rendered paste body
/// <summary>
        /// Test if two circles collides (by Epsicode)
        /// </summary>
        /// <param name="posA">The first circle's position</param>
        /// <param name="radiusA">The first circle's radius</param>
        /// <param name="posB">The second circle's position</param>
        /// <param name="radiusB">The second circle's radius</param>
        /// <returns>true if there is a collision, else false</returns>
        static public bool TestCirclesCollision(Vector2 posA, int radiusA, Vector2 posB, int radiusB)
        {
            if ((posA.X - posB.X) * (posA.X - posB.X)
                + (posA.Y - posB.Y) * (posA.Y - posB.Y)
                < (radiusA + radiusB) * (radiusA + radiusB))
            {
                return true;
            }
            else
            {
                return false;
            }
        }