time for a snapshot
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
import { expect, test } from "bun:test";
|
||||
import { vec } from "./given.ts";
|
||||
import { resolve } from "./resolve.ts";
|
||||
|
||||
test("no collision -> full move", () => {
|
||||
expect(resolve(vec(0, 0), vec(10, 5), null)).toEqual({ x: 10, y: 5 });
|
||||
});
|
||||
|
||||
test("collision at t=0.3 -> stop at contact", () => {
|
||||
const hit = { time: 0.3, normal: vec(-1, 0) };
|
||||
const p = resolve(vec(0, 0), vec(10, 0), hit);
|
||||
expect(p.x).toBeCloseTo(3);
|
||||
expect(p.y).toBeCloseTo(0);
|
||||
});
|
||||
|
||||
test("collision at t=0 -> don't move at all", () => {
|
||||
const hit = { time: 0, normal: vec(-1, 0) };
|
||||
expect(resolve(vec(5, 5), vec(10, 10), hit)).toEqual({ x: 5, y: 5 });
|
||||
});
|
||||
Reference in New Issue
Block a user