rectangles method

bool rectangles (Entity a, Entity b)

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

Implementation

static bool rectangles(Entity a, Entity b) {
  // Upper left of a and not lower left of a
  if ((a.y <= b.y + b.height && a.x <= b.x + b.width) && !(a.y + a.height < b.y || a.x + a.width < b.x)) {
    return true;
  }
  return false;
}