refactor
This commit is contained in:
parent
a633cb7252
commit
6bf8f60a45
5 changed files with 15 additions and 63 deletions
|
@ -1,5 +1,5 @@
|
|||
import { spiral } from "../../common/utils.ts";
|
||||
import { chunks, enumerate, log_from, Vec2 } from "../../common/utils.ts";
|
||||
import { assertEquals } from "https://deno.land/std@0.221.0/assert/mod.ts";
|
||||
import { chunks, enumerate, log_from, spiral, Vec2 } from "../../common/utils.ts";
|
||||
import { Engine, Entity, Query } from "../engine.ts";
|
||||
import { CompDisplay } from "./display.ts";
|
||||
const log = log_from(import.meta);
|
||||
|
@ -53,6 +53,13 @@ function* displacement_steps(position: Vec2, displacement: Vec2) {
|
|||
}
|
||||
}
|
||||
|
||||
Deno.test("test_displacement", () => {
|
||||
assertEquals(
|
||||
[...displacement_steps(new Vec2(1, 1), new Vec2(4, 6))],
|
||||
[new Vec2(2, 2), new Vec2(3, 3), new Vec2(4, 4), new Vec2(5, 5), new Vec2(5, 6), new Vec2(5, 7)],
|
||||
);
|
||||
});
|
||||
|
||||
export function query_at(pos: Vec2) {
|
||||
return Query.filter(CompPos, (c) => c.position.overlaps(pos));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue