Implement collision

Check if there's a wall or other entity where the character is going,
and stop the character from going there
This commit is contained in:
Griffin Smith 2019-09-14 15:10:51 -04:00
parent c06edf3cc6
commit 33c831d23d
2 changed files with 29 additions and 3 deletions

View file

@ -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