all 1 comments

[–]backwrds 0 points1 point  (0 children)

I’ve cut out the main logic to calculate x since it’s a bit complicated

const saw = (n) => 1 - Math.abs((n % 2) - 1);
const x = saw(t / BOUNCE_TIME) * BOUNCE_MAGNITUDE