From 1f1bdd216a9aab01a3886c8929a65f2cc5d929f6 Mon Sep 17 00:00:00 2001 From: nek0 Date: Tue, 15 May 2018 19:27:54 +0200 Subject: [PATCH] reduce liftIO calls --- src/NPC.hs | 8 ++++---- src/Test.hs | 18 +++++++++--------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/NPC.hs b/src/NPC.hs index 87fc3d2..5fd63f0 100644 --- a/src/NPC.hs +++ b/src/NPC.hs @@ -25,15 +25,15 @@ import Types.ReachPoint drawNPCs :: Context + -> UserData -> [V2 Double] -> Double -> Double -> Int -> Int -> Maybe ImgId - -> Affection UserData () -drawNPCs ctx npcposs prow pcol row col img = do - ud <- getAffection + -> IO () +drawNPCs ctx ud npcposs prow pcol row col img = do let fnpcposs = filter (\(V2 nr nc) -> let x = realToFrac $ 640 + ((nc - pcol) + (nr - prow)) * 32 @@ -47,7 +47,7 @@ drawNPCs ctx npcposs prow pcol row col img = do (floor nr == row && floor nc == col) ) npcposs - liftIO $ mapM_ + mapM_ (\(V2 nr nc) -> do let x = realToFrac $ 640 + ((nc - pcol) + (nr - prow)) * 32 y = realToFrac $ 360 + ((nr - prow) - (nc - pcol)) * 16 diff --git a/src/Test.hs b/src/Test.hs index 0ac4620..48cd435 100644 --- a/src/Test.hs +++ b/src/Test.hs @@ -161,15 +161,15 @@ drawMap = do closePath ctx fillColor ctx (rgb 255 255 255) fill ctx - mapM_ (\(i, ls) -> mapM_ - (\(j, t) -> do - liftIO $ drawTile - (assetImages ud) ctx pr pc i j t - drawNPCs ctx npcposs pr pc i j t - ) - (reverse $ zip [1..] ls)) - (zip [1..] (toLists mat)) - liftIO $ do -- draw FPS + mapM_ (\(i, ls) -> mapM_ + (\(j, t) -> do + drawTile + (assetImages ud) ctx pr pc i j t + drawNPCs ctx ud npcposs pr pc i j t + ) + (reverse $ zip [1..] ls)) + (zip [1..] (toLists mat)) + -- liftIO $ do -- draw FPS fontSize ctx 20 fontFace ctx (assetFonts ud Map.! FontBedstead) textAlign ctx (S.fromList [AlignCenter,AlignTop])