colony
Deterministic asteroid physics and orbital belt simulation. Fixed-step
integration over Vec2 state, so replays are bit-identical across backends.
Simulate one step
.rnx
import { Vec2 } from "@std/math";
fn step(pos: Vec2, vel: Vec2, dt: Float): Vec2 {
return new Vec2(pos.x + vel.x * dt, pos.y + vel.y * dt);
}
let p = step(new Vec2(0.0, 0.0), new Vec2(1.5, 0.5), 0.016);
print(p.x, p.y);Belt sweep
.rnx
import { Vec2 } from "@std/math";
let rocks = [new Vec2(1.0, 0.0), new Vec2(0.0, 2.0)];
for r in rocks {
print(r.length());
}