summaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
authorLogan Hunt <loganhunt@simponic.xyz>2022-04-02 23:27:07 -0600
committerLogan Hunt <loganhunt@simponic.xyz>2022-04-02 23:27:07 -0600
commitbb75e40de92fb7e0589410b67e21087f27f34f45 (patch)
tree9c884185bd5feb9d505c4c0ca9a35b31ffb90696 /src/utils
parentcf4dbf91ddb980c051ee2905367143d433c376a5 (diff)
downloadbbiy-bb75e40de92fb7e0589410b67e21087f27f34f45.tar.gz
bbiy-bb75e40de92fb7e0589410b67e21087f27f34f45.zip
Movement bug with two+ pushable entities
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/clamp.js6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/utils/clamp.js b/src/utils/clamp.js
new file mode 100644
index 0000000..b709ee5
--- /dev/null
+++ b/src/utils/clamp.js
@@ -0,0 +1,6 @@
+const clamp = (vector, maxX, maxY) => {
+ const newVector = {...vector};
+ newVector.x = Math.max(0, Math.min(maxX, vector.x));
+ newVector.y = Math.max(0, Math.min(maxY, vector.y));
+ return newVector;
+} \ No newline at end of file