Skip to content

Instantly share code, notes, and snippets.

@oliverbooth
Last active March 15, 2022 16:51
Show Gist options
  • Save oliverbooth/0e4912a50a9af658090311ea5149bbb3 to your computer and use it in GitHub Desktop.
Save oliverbooth/0e4912a50a9af658090311ea5149bbb3 to your computer and use it in GitHub Desktop.
bool CollisionTest()
{
var aRectangle = new Rectangle(_a.X, _a.Y, _a.Width, _a.Height);
var bRectangle = new Rectangle(_b.X, _b.Y, _b.Width, _b.Height);
return Intersects(aRectangle, bRectangle);
}
bool Intersects(Rectangle a, Rectangle b)
{
return (b.X < a.X + a.Width) && (a.X < b.X + b.Width) &&
(b.Y < a.Y + a.Height) && (a.Y < b.Y + b.Height);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment