Beispiel #1
0
        public bool Overlaps(CircleAABB otherCollider)
        {
            Vector2 diff = otherCollider.Center - Center;
            float   r    = Radius + otherCollider.Radius;

            return(MagnitudeSqr(diff) <= (r * r));
        }
        public bool Overlaps(CircleAABB circleCol)
        {
            Vector2 diff = ClosestPoint(circleCol.Center) - circleCol.Center;

            return(circleCol.DotProduct(diff, diff) <= (circleCol.Radius * circleCol.Radius));
            //return true; //placeholder
            //             // TODO: Figure out how to make the overlap check for this.
        }
Beispiel #3
0
        /// <summary>
        /// Box to check for collisions. Box goes around the image (using scales)
        /// </summary>
        /// <param name="boxToCollide"></param>
        public CircleCollider(int _x, int _y, float _radius, int _radiusMultplier = 1)
        {
            //Rectangle _boxToCollide = new Rectangle(_x, _y, _width, _height);
            theCenter        = new Vector2(_x, _y);
            Radius           = _radius;
            Center           = new Vector2(_x, _y);
            RadiusMultiplier = _radiusMultplier;
            //boxContainer = new Rectangle(_boxToCollide.x - theCenter.X,
            //							 _boxToCollide.y - theCenter.Y,
            //							 _boxToCollide.width,
            //							 _boxToCollide.height);


            CollisionBox = new CircleAABB();
            RenderLayer  = Global.BOXCOLLIDER_LAYER;                        //make sure this is drawn first
        }