about summary refs log tree commit diff
path: root/src/Xanthous/App.hs
diff options
context:
space:
mode:
authorGriffin Smith <root@gws.fyi>2019-09-14T19·10-0400
committerGriffin Smith <root@gws.fyi>2019-09-14T19·10-0400
commit33c831d23d09d1e80a1dcfacb373dcedec55f694 (patch)
treef6ac83a343dafc40cfd09e417c9b2fce98eec3fe /src/Xanthous/App.hs
parentc06edf3cc698f36e995719dc6e192c5663110f6d (diff)
Implement collision
Check if there's a wall or other entity where the character is going,
and stop the character from going there
Diffstat (limited to 'src/Xanthous/App.hs')
-rw-r--r--src/Xanthous/App.hs7
1 files changed, 5 insertions, 2 deletions
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