animations

This commit is contained in:
ryanfitzpatrickio
2026-08-03 19:20:00 -05:00
parent fb1ebeed05
commit afd764e5e7
22 changed files with 2049 additions and 212 deletions
+52
View File
@@ -118,6 +118,58 @@ section('a dumped puck slides a long way but does stop');
physics.destroy();
}
section('proximity grab rewards lining up a moving puck');
{
const {
interceptQuality, speedGrabFactor, crowdGrabFactor, CARRY: C,
} = await import('../src/game/possession.js');
const s = { x: 0, z: 0, yaw: Math.PI / 2, vx: 4, vz: 0 };
// Puck ahead on the line (within grab bubble), coming toward the skater.
const onLine = interceptQuality(
s,
{ x: 1.5, y: 0.02, z: 0 },
{ x: -12, y: 0, z: 0 },
C.grabRadius,
);
// Same distance, puck flying wide past the skater.
const wide = interceptQuality(
s,
{ x: 1.5, y: 0.02, z: 1.4 },
{ x: -12, y: 0, z: 0 },
C.grabRadius,
);
ok(onLine > 0.35, `lined-up hard puck is grabable (${onLine.toFixed(2)})`);
ok(onLine > wide + 0.08, `and beats a wide miss (${onLine.toFixed(2)} vs ${wide.toFixed(2)})`);
// Still puck at the feet — easy.
const soft = interceptQuality(
{ x: 0, z: 0, yaw: 0, vx: 0, vz: 0 },
{ x: 0.4, y: 0.02, z: 0.3 },
{ x: 0, y: 0, z: 0 },
C.grabRadius,
);
ok(soft > 0.4, `soft puck nearby is easy (${soft.toFixed(2)})`);
}
section('fast pucks and crowds lower proximity grab odds');
{
const { speedGrabFactor, crowdGrabFactor, CARRY: C } = await import('../src/game/possession.js');
const still = speedGrabFactor(0, C.grabSpeedHalf);
const pass = speedGrabFactor(12, C.grabSpeedHalf);
const slap = speedGrabFactor(35, C.grabSpeedHalf);
ok(still > 0.9, `still puck is free to grab (${still.toFixed(2)})`);
ok(pass < still * 0.55, `a firm pass is harder (${pass.toFixed(2)} vs ${still.toFixed(2)})`);
ok(slap < pass, `a rocket is harder still (${slap.toFixed(2)})`);
ok(slap < 0.2, `slapshot proximity is weak (${slap.toFixed(2)})`);
near(crowdGrabFactor(1, C.grabCrowdK), 1, 1e-9, 'one body: full claim');
ok(crowdGrabFactor(2, C.grabCrowdK) < 0.75, `two bodies cut odds (${crowdGrabFactor(2, C.grabCrowdK).toFixed(2)})`);
ok(
crowdGrabFactor(4, C.grabCrowdK) < crowdGrabFactor(2, C.grabCrowdK),
'more bodies cut further',
);
}
section('a skater picks up a loose puck');
{
const { physics, match } = arena(1);