diff --git a/game.js b/game.js index 997c0b2..54fa926 100644 --- a/game.js +++ b/game.js @@ -164,8 +164,6 @@ function handleMoves() { playerStates[player.state].speed / ([dx, dy].every((d) => d !== 0) ? Math.SQRT2 : 1) - const clamp = (value) => (min, max) => Math.max(min, Math.min(max, value)) - player.position = { x: clamp(player.position.x + dx * norm)( arena.bounds.left, @@ -670,6 +668,10 @@ function arr(n, filler) { return result } +function clamp(value) { + return (min, max) => Math.max(min, Math.min(max, value)) +} + function rnd(from, to) { return Math.floor(Math.random() * (to - from + 1)) + from }