From ffc274d310b14eb663d018a00a64b78ba45d0fc5 Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Wed, 8 Feb 2023 07:16:43 +0000 Subject: Use NoFieldSelectors --- src/Game/Entities.hs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/Game/Entities.hs') diff --git a/src/Game/Entities.hs b/src/Game/Entities.hs index e8267db..96cc4fa 100644 --- a/src/Game/Entities.hs +++ b/src/Game/Entities.hs @@ -63,13 +63,13 @@ append :: Entity -> Entities -> Entities append e (Entities sprites entities) = Entities sprites (entities ++ [e]) processSpawn :: S.SpriteSheet -> Spawn -> IO Entity -processSpawn sprites (DustEffectSpawn x' y') = mkEffect sprites x' y' "dust" +processSpawn sprites (DustEffectSpawn x y) = mkEffect sprites x y "dust" updateAll :: Entities -> IO Entities updateAll (Entities sprites entities) = do updated <- traverse (\e -> e.update e) entities new <- traverse (processSpawn sprites) (concatMap (\e -> e.spawns) updated) - pure $ Entities sprites $ map (\e -> e {spawns = []}) (filter (not . destroy) updated) ++ new + pure $ Entities sprites $ map (\e -> e {spawns = []}) (filter (\e -> not e.destroy) updated) ++ new render :: SDL.Renderer -> Entities -> IO () render renderer (Entities _ entities) = do @@ -82,13 +82,13 @@ render renderer (Entities _ entities) = do set = toSpriteSet e.dir mkEffect :: S.SpriteSheet -> Int -> Int -> String -> IO Entity -mkEffect sprites x' y' name = do +mkEffect sprites x y name = do s <- S.get sprites name pure $ Entity { typ = TypeEffect, - x = x', - y = y', + x = x, + y = y, delay = frameDelay, frame = 0, frameLimit = 3, @@ -109,13 +109,13 @@ updateEffect e | otherwise = e {destroy = True} mkPlayer :: S.SpriteSheet -> Int -> Int -> IORef C.Controls -> (Int -> Int -> Bool) -> IO Entity -mkPlayer sprites x' y' controls isBlocked' = do +mkPlayer sprites x y controls isBlocked' = do s <- S.get sprites "player" pure $ Entity { typ = TypePlayer, - x = x', - y = y', + x = x, + y = y, delay = 0, frame = 0, frameLimit = 3, @@ -140,7 +140,7 @@ updateFrame updated e updateHorizontal :: Bool -> Bool -> Entity -> Entity updateHorizontal left right e - -- prevent pressing both directions (ky'board) + -- prevent pressing both directions (kyboard) | left && right = e -- change direction first | left && e.dir /= DirLeft = e {dir = DirLeft, delay = 0} @@ -199,5 +199,5 @@ updatePlayer controls e = do updateGravity $ updateVertical ctl.a ctl.down $ updateHorizontal ctl.left ctl.right $ - -- left or right, but not both (ky'board) + -- left or right, but not both (keyboard) updateFrame ((ctl.left || ctl.right) && (ctl.left /= ctl.right)) e -- cgit v1.2.3