@Test public void testAdjacentNotCollisions() { AABB first = new AABB(0, 0, 1, 1); List<AABB> compares = new ArrayList<AABB>(); compares.add(new AABB(0, 1, 1, 1)); compares.add(new AABB(1, 0, 1, 1)); compares.add(new AABB(1, 1, 1, 1)); for (AABB aabb : compares) { assert !first.collides(aabb); } }
public boolean collides(AABB other) { if (!activeInCollisions) { return false; } return (Math.abs(posX - other.posX()) + EPSILON < halfWidth + other.halfWidth) && (Math.abs(posY - other.posY()) + EPSILON < halfHeight + other.halfHeight); }
AABB { public boolean collides(AABB other) { if (!activeInCollisions) { return false; } return (Math.abs(posX - other.posX()) + EPSILON < halfWidth + other.halfWidth) && (Math.abs(posY - other.posY()) + EPSILON < halfHeight + other.halfHeight); } }
AABB { public boolean collides(AABB other) { if (!activeInCollisions) { return false; } return (Math.abs(posX - other.posX()) + EPSILON < halfWidth + other.halfWidth) && (Math.abs(posY - other.posY()) + EPSILON < halfHeight + other.halfHeight); } AABB(float posX, float posY, float width, float height, float offsetX, float offsetY);  AABB(float posX, float posY, float width, float height); }
AABB { public boolean collides(AABB other) { if (!activeInCollisions) { return false; } return (Math.abs(posX - other.posX()) + EPSILON < halfWidth + other.halfWidth) && (Math.abs(posY - other.posY()) + EPSILON < halfHeight + other.halfHeight); } AABB(float posX, float posY, float width, float height, float offsetX, float offsetY);  AABB(float posX, float posY, float width, float height); void setActive(boolean value); void makeChild(boolean value); boolean collides(AABB other); BodyPart collides(Entity other); void setPos(AABB otherBounds, int facing); void setPos(float x, float y); void setX(float x); void setRightX(float x); void setY(float y); void setBottomY(float y); float getWidth(); float getHeight(); float getHalfWidth(); float getHalfHeight(); float ownerLeft(); float ownerTop(); float ownerRight(); float ownerBottom(); float left(); float top(); float right(); float bottom(); float posX(); float posY(); void saveCoords(); float startLeft(); float startRight(); float startTop(); float startBottom(); BodyPart getBodyPart(); void setBodyPart(BodyPart bodyPart); void setAABB(float posX, float posY, float width, float height); void render(GraphicsContext gc,  Viewport viewport); @Override String toString(); }
AABB { public boolean collides(AABB other) { if (!activeInCollisions) { return false; } return (Math.abs(posX - other.posX()) + EPSILON < halfWidth + other.halfWidth) && (Math.abs(posY - other.posY()) + EPSILON < halfHeight + other.halfHeight); } AABB(float posX, float posY, float width, float height, float offsetX, float offsetY);  AABB(float posX, float posY, float width, float height); void setActive(boolean value); void makeChild(boolean value); boolean collides(AABB other); BodyPart collides(Entity other); void setPos(AABB otherBounds, int facing); void setPos(float x, float y); void setX(float x); void setRightX(float x); void setY(float y); void setBottomY(float y); float getWidth(); float getHeight(); float getHalfWidth(); float getHalfHeight(); float ownerLeft(); float ownerTop(); float ownerRight(); float ownerBottom(); float left(); float top(); float right(); float bottom(); float posX(); float posY(); void saveCoords(); float startLeft(); float startRight(); float startTop(); float startBottom(); BodyPart getBodyPart(); void setBodyPart(BodyPart bodyPart); void setAABB(float posX, float posY, float width, float height); void render(GraphicsContext gc,  Viewport viewport); @Override String toString();  }