using Microsoft.Xna.Framework; using System; using System.Collections.Generic; using System.Text; namespace Sprint3_actual.Collision_Detection { public enum ICollision { Left, Right, Top, Bottom, None } public class CollisionDetector { public CollisionDetector() { } public ICollision Collision(Rectangle r1, Rectangle r2) { if (!r1.Intersects(r2)) { return ICollision.None; } else { Rectangle intersection = Rectangle.Intersect(r1, r2); if (intersection.Width > intersection.Height && r2.Y < r1.Y) { return ICollision.Top; } else if (intersection.Width > intersection.Height && r2.Y > r1.Y) { return ICollision.Bottom; } else if (intersection.Width < intersection.Height && r2.X > r1.X) { return ICollision.Right; } else if (intersection.Width < intersection.Height && r2.X < r1.X) { return ICollision.Left; } else { return ICollision.None; } } } } }