reduce liftIO calls

This commit is contained in:
nek0 2018-05-15 19:27:54 +02:00
parent 8a620f742e
commit 1f1bdd216a
2 changed files with 13 additions and 13 deletions

View file

@ -25,15 +25,15 @@ import Types.ReachPoint
drawNPCs drawNPCs
:: Context :: Context
-> UserData
-> [V2 Double] -> [V2 Double]
-> Double -> Double
-> Double -> Double
-> Int -> Int
-> Int -> Int
-> Maybe ImgId -> Maybe ImgId
-> Affection UserData () -> IO ()
drawNPCs ctx npcposs prow pcol row col img = do drawNPCs ctx ud npcposs prow pcol row col img = do
ud <- getAffection
let fnpcposs = filter let fnpcposs = filter
(\(V2 nr nc) -> (\(V2 nr nc) ->
let x = realToFrac $ 640 + ((nc - pcol) + (nr - prow)) * 32 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) (floor nr == row && floor nc == col)
) )
npcposs npcposs
liftIO $ mapM_ mapM_
(\(V2 nr nc) -> do (\(V2 nr nc) -> do
let x = realToFrac $ 640 + ((nc - pcol) + (nr - prow)) * 32 let x = realToFrac $ 640 + ((nc - pcol) + (nr - prow)) * 32
y = realToFrac $ 360 + ((nr - prow) - (nc - pcol)) * 16 y = realToFrac $ 360 + ((nr - prow) - (nc - pcol)) * 16

View file

@ -163,13 +163,13 @@ drawMap = do
fill ctx fill ctx
mapM_ (\(i, ls) -> mapM_ mapM_ (\(i, ls) -> mapM_
(\(j, t) -> do (\(j, t) -> do
liftIO $ drawTile drawTile
(assetImages ud) ctx pr pc i j t (assetImages ud) ctx pr pc i j t
drawNPCs ctx npcposs pr pc i j t drawNPCs ctx ud npcposs pr pc i j t
) )
(reverse $ zip [1..] ls)) (reverse $ zip [1..] ls))
(zip [1..] (toLists mat)) (zip [1..] (toLists mat))
liftIO $ do -- draw FPS -- liftIO $ do -- draw FPS
fontSize ctx 20 fontSize ctx 20
fontFace ctx (assetFonts ud Map.! FontBedstead) fontFace ctx (assetFonts ud Map.! FontBedstead)
textAlign ctx (S.fromList [AlignCenter,AlignTop]) textAlign ctx (S.fromList [AlignCenter,AlignTop])