Пример #1
0
        protected bool collide(List <CollisionPair> collisions, CircleShell a, CircleShell b)
        {
            //for future use: will have conditionals here for the different shell types


            float collision = a.radius + b.radius;

            //calc current distance
            Vec2 distance = new Vec2((b.position.x - a.position.x), (b.position.y - a.position.y));

            //check if they overlap
            float overlap = collision - distance.GetMag();

            //if they overlap, create a new pair and add it to the list
            if (overlap <= collision && overlap >= 0.0f)
            {
                CollisionPair cpair = new CollisionPair(a, b, (distance * overlap));
                collisions.Add(cpair);
                return(true);
            }

            else
            {
                return(false);
            }
        }
Пример #2
0
        protected bool collide(List<CollisionPair> collisions, CircleShell a, CircleShell b)
        {
            //for future use: will have conditionals here for the different shell types

            float collision = a.radius + b.radius;

            //calc current distance
            Vec2 distance = new Vec2((b.position.x - a.position.x), (b.position.y - a.position.y));

            //check if they overlap
            float overlap = collision - distance.GetMag();

            //if they overlap, create a new pair and add it to the list
            if (overlap <= collision && overlap >= 0.0f)
            {
                CollisionPair cpair = new CollisionPair(a, b, (distance * overlap));
                collisions.Add(cpair);
                return true;
            }

            else
            {
                return false;
            }
        }