17 lines
354 B
TypeScript
17 lines
354 B
TypeScript
import { Point } from "../geometry/vector.ts";
|
|
|
|
export type axisAlignedBoundingBox = {
|
|
w: number;
|
|
h: number;
|
|
} & Point;
|
|
|
|
export const axisAlignedCollision = (
|
|
aa1: axisAlignedBoundingBox,
|
|
aa2: axisAlignedBoundingBox,
|
|
) => {
|
|
return aa1.x < aa2.x + aa2.w &&
|
|
aa1.x + aa1.w > aa2.x &&
|
|
aa1.y < aa2.y + aa2.h &&
|
|
aa1.y + aa1.h > aa2.y;
|
|
};
|