From: sabadev Date: Thu, 4 Feb 2021 00:48:43 +0000 (-0500) Subject: Removed some redundancy from limitCoords X-Git-Url: http://sabadev.xyz:4321/?a=commitdiff_plain;h=c989c37a9282d8ef9a6f269a6c14997571abafec;p=avoidance.git Removed some redundancy from limitCoords --- diff --git a/src/Game.hs b/src/Game.hs index a0726c7..670f992 100644 --- a/src/Game.hs +++ b/src/Game.hs @@ -199,15 +199,11 @@ moveCharacter (Just R) character = updatePosition (0, 1) character moveCharacter _ character = character limitCoords :: G.Coords -> G.Coords -limitCoords (a, b) = (limitRowCoord a, limitColumnCoord b) +limitCoords (a, b) = (limitCoord snd a, limitCoord fst b) where - limitRowCoord a - | a < snd topLeftBoundary = snd topLeftBoundary - | a > snd bottomRightBoundary = snd bottomRightBoundary - | otherwise = a - limitColumnCoord a - | a < fst topLeftBoundary = fst topLeftBoundary - | a > fst bottomRightBoundary = fst bottomRightBoundary + limitCoord projection a + | a < projection topLeftBoundary = projection topLeftBoundary + | a > projection bottomRightBoundary = projection bottomRightBoundary | otherwise = a updatePosition :: G.Coords -> Character t -> Character t