UNPKG

@woosh/meep-engine

Version:

Pure JavaScript game engine. Fully featured and production ready.

12 lines (10 loc) 264 B
import { euclidean_modulo } from "./euclidean_modulo.js"; /** * * @param {number} x * @param {number} length * @return {number} */ export function pingpong(x, length = 1) { return length - Math.abs(euclidean_modulo(x, length * 2) - length); }