From: sabadev Date: Sun, 31 Jan 2021 14:25:18 +0000 (-0500) Subject: Added render method. X-Git-Url: http://sabadev.xyz:4321/?a=commitdiff_plain;h=d9a2642010fd79254437f9b9b2a5b7fa93dab41d;p=avoidance.git Added render method. --- diff --git a/src/Game.hs b/src/Game.hs index 9eb386e..79e2c09 100644 --- a/src/Game.hs +++ b/src/Game.hs @@ -25,14 +25,14 @@ data Character t = Character { entityCoords :: !G.Coords , entityVelocity :: !Velocity } -drawPlayer :: Character Player -> G.Plane -drawPlayer _ = G.cell '&' +drawPlayer :: Character Player -> (G.Coords, G.Plane) +drawPlayer character = (entityCoords character, G.cell '&') -drawBox :: Character Box -> G.Plane -drawBox _ = G.cell 'O' +drawBox :: Character Box -> (G.Coords, G.Plane) +drawBox character = (entityCoords character, G.cell 'O') -drawEnemy :: Character Enemy -> G.Plane -drawEnemy _ = G.cell 'X' +drawEnemy :: Character Enemy -> (G.Coords, G.Plane) +drawEnemy character = (entityCoords character, G.cell 'X') data State = State { stateDirection :: ![Direction] , statePlayer :: !(Character Player) @@ -74,10 +74,15 @@ initEnemies :: [Character Enemy] initEnemies = mempty handleEvent :: State -> G.Event -> State -handleEvent = undefined +handleEvent state _ = state render :: State -> G.Plane -render = undefined +render state = do + let playerPlane = drawPlayer $ statePlayer state + let boxPlane = drawBox $ stateBox state + let enemyPlanes = drawEnemy <$> stateEnemy state + let blank = G.blankPlane (fst bottomRightBoundary) (snd bottomRightBoundary) + G.mergePlanes blank $ playerPlane : boxPlane : enemyPlanes shouldQuit :: State -> Bool shouldQuit = stateIsQuitting