Skip to content

Instantly share code, notes, and snippets.

@themisir
Last active September 12, 2018 18:44
Show Gist options
  • Save themisir/da8448925315b5f4ec738b2dc7b437eb to your computer and use it in GitHub Desktop.
Save themisir/da8448925315b5f4ec738b2dc7b437eb to your computer and use it in GitHub Desktop.
private boolean clamp(float value, float min, float max) {
return Math.max(min, Math.min(max, value));
}
public boolean collides(Rectangle r1, Circle c1) {
float cx = clamp(c1.x, r1.left(), r1.right());
float cy = clamp(c1.y, r1.top(), r1.bottom());
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment