From 26ab30dd9a7a92354cb60c21e87467f073a23ca0 Mon Sep 17 00:00:00 2001 From: He4eT Date: Wed, 18 Jun 2025 20:27:38 +0200 Subject: [PATCH] game: clamp: data last --- game.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/game.js b/game.js index 42ae179..dcef212 100644 --- a/game.js +++ b/game.js @@ -161,14 +161,14 @@ function handleMoves() { ([dx, dy].every((d) => d !== 0) ? Math.SQRT2 : 1) player.position = { - x: clamp(player.position.x + dx * norm)( + x: clamp( arena.bounds.left, arena.bounds.right, - ), - y: clamp(player.position.y + dy * norm)( + )(player.position.x + dx * norm), + y: clamp( arena.bounds.top, arena.bounds.bottom, - ), + )(player.position.y + dy * norm), } } @@ -660,8 +660,8 @@ function arr(n, filler) { return result } -function clamp(value) { - return (min, max) => Math.max(min, Math.min(max, value)) +function clamp(min, max) { + return (value) => Math.max(min, Math.min(max, value)) } function rnd(from, to, seed) {