add enemy ia

This commit is contained in:
Matthieu Jolimaitre 2024-04-10 03:15:15 +02:00
parent 55a5adcd92
commit 328d508ae7
2 changed files with 47 additions and 0 deletions

View file

@ -224,6 +224,14 @@ export class Vec2 {
public clone() {
return new Vec2(this.x(), this.y());
}
public normalize() {
return new Vec2(clamp(this.x(), -1, 1), clamp(this.y(), -1, 1));
}
}
export function clamp(x: number, min: number, max: number) {
return Math.max(min, Math.min(x, max));
}
export function v2(x: number, y: number) {