Put a test gormlak on the screen

Implement a concrete "Creature" entity, and place one on the screen at
the game startup for testing.

This revealed a bug with drawing when getting the maximum entity
position, but that appears to be fixed now (yay)
This commit is contained in:
Griffin Smith 2019-09-02 14:45:36 -04:00
parent 4d270712ae
commit 73a52e531d
5 changed files with 66 additions and 19 deletions

View file

@ -35,16 +35,15 @@ drawMessages (MessageHistory (lastMessage :| _) True) = txt lastMessage
-- (MessageHistory (lastMessage :| _) True) -> txt lastMessage
drawEntities :: (Draw a, Show a) => EntityMap a -> Widget Name
drawEntities em@(fromNullable . positions -> Just entityPositions)
drawEntities em
= vBox rows
where
maxPosition = maximum entityPositions
maxY = maxPosition ^. y
maxX = maxPosition ^. x
entityPositions = positions em
maxY = fromMaybe 0 $ maximumOf (folded . y) entityPositions
maxX = fromMaybe 0 $ maximumOf (folded . x) entityPositions
rows = mkRow <$> [0..maxY]
mkRow rowY = hBox $ renderEntityAt . flip Position rowY <$> [0..maxX]
renderEntityAt pos = maybe (str " ") draw $ em ^? atPosition pos . folded
drawEntities _ = emptyWidget
drawMap :: GameState -> Widget Name
drawMap game