private bool BoundingBoxCollides(CollisionBoundingBox a, CollisionGeometry b) { if (b is CollisionBoundingBox) { return(a.Intersects((CollisionBoundingBox)b)); } if (b is CollisionCircle) { return(a.Intersects((CollisionCircle)b)); } return(false); }
public bool Intersects(CollisionBoundingBox other) { // See https://stackoverflow.com/a/402019/2442468 for how to do collision // Option 1: Circle center is within boundingbox if (other.Intersects(this.Center)) { return(true); } // Option 2, BoundingBox has a point inside the circle if (this.Intersects(other.BoundingRect.TopLeft())) { return(true); } if (this.Intersects(other.BoundingRect.TopRight())) { return(true); } if (this.Intersects(other.BoundingRect.BottomLeft())) { return(true); } if (this.Intersects(other.BoundingRect.BottomRight())) { return(true); } // No collision detected return(false); }
public static bool Intersects(CollisionBoundingBox a, Rectangle b) => a.Intersects(b);