UNPKG

@woosh/meep-engine

Version:

Pure JavaScript game engine. Fully featured and production ready.

24 lines (18 loc) 657 B
import { aabb2_compute_center_from_multiple } from "../../../geom/2d/aabb/aabb2_compute_center_from_multiple.js"; import { pullBoxTowardsPoint } from "./pullBoxTowardsPoint.js"; /** * * @param {(AABB2|{locked:boolean})[]} boxes * @param {number} strength */ export function applyCentralGravityAABB2(boxes, strength) { const numBoxes = boxes.length; const center = aabb2_compute_center_from_multiple(boxes); for (let i = 0; i < numBoxes; i++) { const box = boxes[i]; if (box.locked === true) { continue; } pullBoxTowardsPoint(box, center.x, center.y, strength); } }