platformer - v1.0.0
    Preparing search index...

    Function intersects

    • Determines whether two axis-aligned rectangles intersect.

      The rectangles are defined by their top-left position (Vector) and their dimensions (Size). This function performs an axis-aligned bounding box (AABB) collision check.

      Parameters

      • aPos: Vector

        Top-left position of rectangle A.

      • aSize: Size

        Dimensions (width and height) of rectangle A.

      • bPos: Vector

        Top-left position of rectangle B.

      • bSize: Size

        Dimensions (width and height) of rectangle B.

      Returns boolean

      true if the rectangles overlap, otherwise false.

      • Assumes rectangles are axis-aligned (not rotated).
      • Edges touching without overlapping will return false.
      const collision = intersects(
      { x: 10, y: 10 },
      { width: 50, height: 50 },
      { x: 40, y: 40 },
      { width: 30, height: 30 }
      );