time for a snapshot
This commit is contained in:
@@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user