circles method

bool circles (Entity a, Entity b)

Checks if two entities with circle shape overlap or touch by checking the boundaries of both entities

Implementation

static bool circles(Entity a, Entity b) {
  double ra = (a.width / 2);
  double rb = (b.width / 2);

  double xa = a.x + ra;
  double ya = a.y + ra;

  double xb = b.x + rb;
  double yb = b.y + rb;

  if (ra + rb >= sqrt(pow(xa - xb, 2) + pow(ya - yb, 2))) {
    return true;
  }
  return false;
}