Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class AABB
- {
- protected Vector2 center, halfSize;
- public AABB(Vector2 center, Vector2 halfSize)
- {
- this.center = center;
- this.halfSize = halfSize;
- }
- public static boolean collides(AABB a, AABB b)
- {
- if(Math.abs(a.center.x - b.center.x) < a.halfSize.x + b.halfSize.x)
- {
- if(Math.abs(a.center.y - b.center.y) < a.halfSize.y + b.halfSize.y)
- {
- return true;
- }
- }
- return false;
- }
- public static boolean inside(AABB a, Vector2Float b)
- {
- if(Math.abs(a.center.x - b.center.x) < a.halfSize.x)
- {
- if(Math.abs(a.center.y - b.center.y) < a.halfSize.y)
- {
- return true;
- }
- }
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement