diff options
author | Juan J. Martinez <jjm@usebox.net> | 2023-02-08 07:16:43 +0000 |
---|---|---|
committer | Juan J. Martinez <jjm@usebox.net> | 2023-02-08 07:16:43 +0000 |
commit | ffc274d310b14eb663d018a00a64b78ba45d0fc5 (patch) | |
tree | f081426939e181d7fe81bc0fe1e1ef7a4f8c87cc /src/Game | |
parent | 6c4ea0fd4831e887103fafe6587e1c6a73914833 (diff) | |
download | space-plat-hs-ffc274d310b14eb663d018a00a64b78ba45d0fc5.tar.gz space-plat-hs-ffc274d310b14eb663d018a00a64b78ba45d0fc5.zip |
Use NoFieldSelectors
Diffstat (limited to 'src/Game')
-rw-r--r-- | src/Game/Entities.hs | 20 |
1 files changed, 10 insertions, 10 deletions
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 |