示例#1
0
 public override bool Intersects(Shape other)
 {
     /* xdiff is the difference in the x component of the vectors
      * ydiff is the difference in y
      * radsum is the sum of the radii
      * Using the distance formula without the square roots because performance
      * dx^2 + dy^2 > r^2 means that the two circles aren't intersecting
      * dx^2 + dy^2 <= r^2 means they're intersecting
      */
     Circle c = other as Circle;
     // Add their velocities to their positions
     if (c.collisionSphere.Intersects(collisionSphere)) {
         if (c.collisionSphere.Contains(collisionSphere) == ContainmentType.Contains || collisionSphere.Contains(c.collisionSphere) == ContainmentType.Contains)
             return false;
         return true;
     }
     else return false;
 }
示例#2
0
        public override bool Intersects(Shape other)
        {
            /* xdiff is the difference in the x component of the vectors
             * ydiff is the difference in y
             * radsum is the sum of the radii
             * Using the distance formula without the square roots because performance
             * dx^2 + dy^2 > r^2 means that the two circles aren't intersecting
             * dx^2 + dy^2 <= r^2 means they're intersecting
             */
            Circle c = other as Circle;
            // Add their velocities to their positions
            Vector2 changePos = c.Position - position;
            float radsum = radius + c.radius;

            if (changePos.LengthSquared() <= radsum * radsum) {
                if ((changePos + velocity + c.velocity).LengthSquared() <= radsum * radsum)
                    return true;
                else
                    return false;
            }
            else
                return false;
        }
示例#3
0
 public abstract bool Intersects(Shape other);
 public Primitive(Shape shape, Texture2D tex)
 {
     type = shape;
     texture = tex;
     mass = 200;
 }