diff --git a/src-server/Server/Communication/Handler.hs b/src-server/Server/Communication/Handler.hs index 6215253..5631ac7 100644 --- a/src-server/Server/Communication/Handler.hs +++ b/src-server/Server/Communication/Handler.hs @@ -11,13 +11,15 @@ import Control.Monad.State import Data.List +import qualified Data.Matrix as M + import Data.Maybe import Data.Time import Data.UUID.V4 -import Linear (angle, perp) +import Linear import System.Random (randomRIO) @@ -142,6 +144,7 @@ handleMessage stateContainer readerContainer msg = do (pure ()) (\player -> do let wiz = playerWizard player + mat = rcMap readerContainer rotStep = pi / 18 newRot = wizardRot wiz + case act of TurnLeft -> -rotStep @@ -155,9 +158,10 @@ handleMessage stateContainer readerContainer msg = do StrifeLeft -> -(perp (angle (-newRot))) _ -> 0 ) + doesCollide (V2 prow pcol) = (M.safeGet (floor prow) (floor pcol) mat) == Just Wall newWiz = wiz { wizardRot = newRot - , wizardPos = newPos + , wizardPos = if doesCollide newPos then wizardPos wiz else newPos } newPlayer = player { playerWizard = newWiz