time for a snapshot

This commit is contained in:
Schluffe
2026-07-11 17:48:28 +02:00
parent 135b7c3042
commit 7262752e16
47 changed files with 1712 additions and 61 deletions
+11
View File
@@ -0,0 +1,11 @@
import { add, type Hit, scale, type Vec } from "./given.ts";
/**
* The new position after this frame's move, stopping at a collision if there is
* one.
* hit === null -> pos + v (take the whole move)
* hit -> pos + v * time (stop at the contact point)
*/
export function resolve(pos: Vec, v: Vec, hit: Hit | null): Vec {
return hit ? add(pos, scale(v, hit.time)) : add(pos, v);
}