Created
January 7, 2017 16:15
-
-
Save matthewd673/d50eca25a5026bc42e74cdcee375e144 to your computer and use it in GitHub Desktop.
simple collision detection in c#
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static bool detectCollision(Rectangle rect1, Rectangle rect2) | |
{ | |
if (rect1.X < (rect2.X + rect2.Width) && | |
(rect1.X + rect1.Width) > rect2.X && | |
rect1.Y < (rect2.Y + rect2.Height) && | |
(rect1.Height + rect1.Y) > rect2.Y) | |
return true; | |
else | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment