예제 #1
0
        public bool CollideAgainstBounce(AxisAlignedRectangle rectangle, float thisMass, float otherMass, float elasticity)
        {
#if DEBUG
            if (thisMass == 0 && otherMass == 0)
            {
                throw new ArgumentException("Both masses cannot be 0.  For equal masses pick a non-zero value");
            }
#endif
            if (CollideAgainstMove(rectangle, thisMass, otherMass))
            {
                if (YVelocity + 103.6 < .01f)
                {
                    int m = 3;
                }

                PositionedObject thisTopParent  = this.TopParent;
                PositionedObject otherTopParent = rectangle.TopParent;

                Vector2 collisionNormal = LastMoveCollisionReposition;

                if (otherMass == 0)
                {
                    collisionNormal = new Vector2(-rectangle.LastMoveCollisionReposition.X, -rectangle.LastMoveCollisionReposition.Y);
                }

                ShapeManager.ApplyBounce(thisTopParent, otherTopParent, thisMass, otherMass, elasticity, ref collisionNormal);
                return(true);
            }

            return(false);
        }
예제 #2
0
        public bool CollideAgainstBounce(Polygon polygon, float thisMass, float otherMass, float elasticity)
        {
#if DEBUG
            if (thisMass == 0 && otherMass == 0)
            {
                throw new ArgumentException("Both masses cannot be 0.  For equal masses pick a non-zero value");
            }
#endif
            if (CollideAgainstMove(polygon, thisMass, otherMass))
            {
                PositionedObject thisTopParent  = this.TopParent;
                PositionedObject otherTopParent = polygon.TopParent;


                Vector2 collisionNormal = LastMoveCollisionReposition;

                if (otherMass == 0)
                {
                    collisionNormal = new Vector2(-polygon.LastMoveCollisionReposition.X, -polygon.LastMoveCollisionReposition.Y);
                }

                ShapeManager.ApplyBounce(thisTopParent, otherTopParent, thisMass, otherMass, elasticity, ref collisionNormal);


                return(true);
            }

            return(false);
        }