Three types of collision and a polygon class

This commit is contained in:
2023-11-03 04:51:50 -06:00
parent a7e7cd139f
commit 601bc51233
10 changed files with 561 additions and 125 deletions

16
collision/aa.ts Normal file
View File

@@ -0,0 +1,16 @@
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;
};