animations

This commit is contained in:
ryanfitzpatrickio
2026-08-03 16:04:46 -05:00
parent 8b28e299e6
commit fb1ebeed05
28 changed files with 5246 additions and 105 deletions
+28
View File
@@ -1,5 +1,8 @@
import { SKATE, applyIntent, createSkaterState, speedOf, stepSkater } from '../shared/skaterSim.js';
import { RINK, insideRink } from '../shared/rink.js';
import {
normalizePlayer, normalizeShotSide, packPlayer, rollShotSide, shotSign, unpackPlayer,
} from '../shared/player.js';
import { done, near, ok, section } from './harness.mjs';
const DT = 1 / 120;
@@ -234,6 +237,7 @@ section('intent from a controller is clamped before the sim sees it');
// The clamped state must still step without producing garbage.
stepSkater(s, DT);
ok(Number.isFinite(s.x) && Number.isFinite(s.vx), 'and the sim steps cleanly afterwards');
}
@@ -243,4 +247,28 @@ section('rink dimensions are the ones we think they are');
near(RINK.halfZ * 2, 25.9, 0.02, 'and 85 feet wide');
}
section('player definition carries shot side');
{
ok(normalizeShotSide('left') === 'left', 'left stays left');
ok(normalizeShotSide('L') === 'left', 'L is left');
ok(normalizeShotSide(-1) === 'left', '-1 is left');
ok(normalizeShotSide('right') === 'right', 'right stays right');
ok(normalizeShotSide('R') === 'right', 'R is right');
ok(normalizeShotSide(undefined) === 'right', 'missing defaults to right (authored side)');
ok(shotSign('left') === -1 && shotSign('right') === 1, 'shotSign is ±1');
ok(rollShotSide(0.1) === 'left' && rollShotSide(0.9) === 'right', 'roll respects the NHL-ish split');
const packed = packPlayer({ shotSide: 'left' });
ok(packed.ss === 'L', 'pack uses a short wire form');
ok(unpackPlayer(packed).shotSide === 'left', 'unpack restores shot side');
ok(normalizePlayer({ shotSide: 'left' }).shotSide === 'left', 'normalizePlayer keeps shot side');
const lefty = createSkaterState(0, START, { shotSide: 'left', name: 'Lefty' });
const righty = createSkaterState(1, START, { shotSide: 'right' });
const plain = createSkaterState(2, START);
ok(lefty.shotSide === 'left', 'state stores left shot');
ok(righty.shotSide === 'right', 'state stores right shot');
ok(plain.shotSide === 'right', 'state defaults to right shot');
}
done('skaterSim');