From 33c831d23d09d1e80a1dcfacb373dcedec55f694 Mon Sep 17 00:00:00 2001 From: Griffin Smith Date: Sat, 14 Sep 2019 15:10:51 -0400 Subject: Implement collision Check if there's a wall or other entity where the character is going, and stop the character from going there --- src/Xanthous/App.hs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/Xanthous/App.hs') diff --git a/src/Xanthous/App.hs b/src/Xanthous/App.hs index 0dc24b9d41..82c32f05a3 100644 --- a/src/Xanthous/App.hs +++ b/src/Xanthous/App.hs @@ -16,7 +16,6 @@ import Xanthous.Data , Dimensions , positionFromPair ) -import qualified Xanthous.Data.EntityMap as EntityMap import Xanthous.Data.EntityMap (EntityMap) import Xanthous.Game import Xanthous.Game.Draw (drawGame) @@ -74,7 +73,11 @@ handleEvent _ = continue handleCommand :: Command -> AppM (Next GameState) handleCommand Quit = halt handleCommand (Move dir) = do - characterPosition %= move dir + newPos <- uses characterPosition $ move dir + collisionAt newPos >>= \case + Nothing -> characterPosition .= newPos + Just Combat -> undefined + Just Stop -> pure () continue handleCommand PreviousMessage = do -- cgit 1.4.1