Refactor codebase
This commit is contained in:
17
src/core/math.ts
Normal file
17
src/core/math.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import type { Vec2 } from "./types";
|
||||
|
||||
export function seededRandom(seed: number): () => number {
|
||||
let state = seed;
|
||||
return () => {
|
||||
state = (state * 1103515245 + 12345) & 0x7fffffff;
|
||||
return state / 0x7fffffff;
|
||||
};
|
||||
}
|
||||
|
||||
export function manhattan(a: Vec2, b: Vec2): number {
|
||||
return Math.abs(a.x - b.x) + Math.abs(a.y - b.y);
|
||||
}
|
||||
|
||||
export function lerp(a: number, b: number, t: number): number {
|
||||
return a + (b - a) * t;
|
||||
}
|
||||
Reference in New Issue
Block a user