Exemplo n.º 1
0
        /// <summary>
        /// Returns a Vector2D dictating a point on the tank's radius relative to the angle of the
        /// object (projectile / powerup). Used for collision detection for Tanks calulated as a circle
        /// and another objects locatiton Vector2D.
        /// </summary>
        /// <param name="tank">Vector2D location of the tank</param>
        /// <param name="obj">Vector2D location of the object</param>
        /// <param name="tankWidth">Width of the tank</param>
        /// <returns></returns>
        private Vector2D GetTankRadius(Vector2D tank, Vector2D obj, double tankWidth)
        {
            double radius = tankWidth / 2;
            float  angle  = Vector2D.AngleBetweenPoints(tank, obj);

            float x = (float)(Math.Cos(angle) * radius);
            float y = (float)(Math.Sin(angle) * radius);

            return(new Vector2D(x, y));
        }