diff options
author | Griffin Smith <root@gws.fyi> | 2019-09-02T18·45-0400 |
---|---|---|
committer | Griffin Smith <root@gws.fyi> | 2019-09-02T18·45-0400 |
commit | 73a52e531d940858f0ac334d8b2ccda479ea7b5e (patch) | |
tree | fc7a953ddcb69691e2f734fa69f4585aff553e17 /src/Xanthous/Game/Draw.hs | |
parent | 4d270712aecf1b61249086718852b96968de2bd8 (diff) |
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)
Diffstat (limited to 'src/Xanthous/Game/Draw.hs')
-rw-r--r-- | src/Xanthous/Game/Draw.hs | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/Xanthous/Game/Draw.hs b/src/Xanthous/Game/Draw.hs index 6527af743953..36abe161198e 100644 --- a/src/Xanthous/Game/Draw.hs +++ b/src/Xanthous/Game/Draw.hs @@ -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 |