From 73a52e531d940858f0ac334d8b2ccda479ea7b5e Mon Sep 17 00:00:00 2001 From: Griffin Smith Date: Mon, 2 Sep 2019 14:45:36 -0400 Subject: 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) --- src/Xanthous/Game/Draw.hs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/Xanthous/Game/Draw.hs') 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 -- cgit 1.4.1