diff options
| author | troido <troido@protonmail.com> | 2020-01-29 22:53:06 +0100 |
|---|---|---|
| committer | troido <troido@protonmail.com> | 2020-01-29 22:53:06 +0100 |
| commit | 286be37225b5de1fb438db0a4029fd391b35c13e (patch) | |
| tree | c865ca269f43d7666275d1d72096dad805135705 /src/util.rs | |
| parent | 88f275bc427033b7981e0dc2fc5cb4b711fd5fb1 (diff) | |
players can no longer walk through walls
Diffstat (limited to 'src/util.rs')
| -rw-r--r-- | src/util.rs | 8 |
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); +} + |
