summaryrefslogtreecommitdiff
path: root/src/util.rs
diff options
context:
space:
mode:
authortroido <troido@protonmail.com>2020-01-29 22:53:06 +0100
committertroido <troido@protonmail.com>2020-01-29 22:53:06 +0100
commit286be37225b5de1fb438db0a4029fd391b35c13e (patch)
treec865ca269f43d7666275d1d72096dad805135705 /src/util.rs
parent88f275bc427033b7981e0dc2fc5cb4b711fd5fb1 (diff)
players can no longer walk through walls
Diffstat (limited to 'src/util.rs')
-rw-r--r--src/util.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/util.rs b/src/util.rs
new file mode 100644
index 0000000..1e7821f
--- /dev/null
+++ b/src/util.rs
@@ -0,0 +1,8 @@
+
+
+use std::cmp::{min, max};
+
+pub fn clamp<T: Ord>(val: T, lower: T, upper: T) -> T{
+ return max(min(val, upper), lower);
+}
+