Skip to content

Instantly share code, notes, and snippets.

@themisir
Created September 12, 2018 18:33
Show Gist options
  • Save themisir/9c119ceae46e4d122068797bb5d3d849 to your computer and use it in GitHub Desktop.
Save themisir/9c119ceae46e4d122068797bb5d3d849 to your computer and use it in GitHub Desktop.
public boolean collides(Rectangle r1, Rectangle r2) {
return
(r2.left() >= r1.left() && r2.left() <= r1.right()) ||
(r2.right() >= r1.left() && r2.right() <= r1.right()) ||
(r2.top() >= r1.top() && r2.top() <= r1.bottom()) ||
(r2.bottom() >= r1.top() && r2.bottom() <= r1.bottom());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment