diff options
author | Juan J. Martinez <jjm@usebox.net> | 2023-02-24 22:51:42 +0000 |
---|---|---|
committer | Juan J. Martinez <jjm@usebox.net> | 2023-02-24 22:51:42 +0000 |
commit | e066422b950a06873efb6a884b47155c867b7acf (patch) | |
tree | 833c0ac83cdb66ec50f3ef882598d3b93004cf12 /src/Game/Entities | |
parent | cf01ddef562c64dbcffa2770f50825cd97f02e3f (diff) | |
download | space-plat-hs-e066422b950a06873efb6a884b47155c867b7acf.tar.gz space-plat-hs-e066422b950a06873efb6a884b47155c867b7acf.zip |
Cleaned passing the collision detection function to the entities
Diffstat (limited to 'src/Game/Entities')
-rw-r--r-- | src/Game/Entities/Pickup.hs | 7 | ||||
-rw-r--r-- | src/Game/Entities/Robot.hs | 7 | ||||
-rw-r--r-- | src/Game/Entities/Slime.hs | 7 |
3 files changed, 9 insertions, 12 deletions
diff --git a/src/Game/Entities/Pickup.hs b/src/Game/Entities/Pickup.hs index 8d8beb8..4aa7326 100644 --- a/src/Game/Entities/Pickup.hs +++ b/src/Game/Entities/Pickup.hs @@ -1,13 +1,12 @@ module Game.Entities.Pickup (mkBattery) where -import Data.IORef import Game.Entities.Common import Game.Entities.Const import Game.Entities.Types import qualified Game.Sprites as S -mkBattery :: S.SpriteSheet -> Int -> Int -> IORef Entity -> IO () -> IO Entity -mkBattery sprites x y playerRef collectedBattery' = do +mkBattery :: S.SpriteSheet -> Int -> Int -> Collision -> IO () -> IO Entity +mkBattery sprites x y playerCollision collectedBattery' = do s <- S.get sprites "battery" pure Entity @@ -20,7 +19,7 @@ mkBattery sprites x y playerRef collectedBattery' = do gravity = gravityOff, dir = DirRight, sprite = s, - update = updateBattery (collision playerRef 16) collectedBattery', + update = updateBattery playerCollision collectedBattery', destroy = False, spawns = [] } diff --git a/src/Game/Entities/Robot.hs b/src/Game/Entities/Robot.hs index 64c9d48..39b63aa 100644 --- a/src/Game/Entities/Robot.hs +++ b/src/Game/Entities/Robot.hs @@ -1,14 +1,13 @@ module Game.Entities.Robot (mkRobot) where import Data.Bits (Bits (..)) -import Data.IORef import Game.Entities.Common import Game.Entities.Const import Game.Entities.Types import qualified Game.Sprites as S -mkRobot :: S.SpriteSheet -> Int -> Int -> IORef Entity -> IsBlocked -> IO () -> IO Entity -mkRobot sprites x y playerRef isBlocked hitPlayer' = do +mkRobot :: S.SpriteSheet -> Int -> Int -> Collision -> IsBlocked -> IO () -> IO Entity +mkRobot sprites x y playerCollision isBlocked hitPlayer' = do s <- S.get sprites "robot" pure Entity @@ -21,7 +20,7 @@ mkRobot sprites x y playerRef isBlocked hitPlayer' = do gravity = gravityOff, dir = DirRight, sprite = s, - update = updateRobot (collision playerRef 24) isBlocked hitPlayer', + update = updateRobot playerCollision isBlocked hitPlayer', destroy = False, spawns = [] } diff --git a/src/Game/Entities/Slime.hs b/src/Game/Entities/Slime.hs index d87f735..5ca6fe7 100644 --- a/src/Game/Entities/Slime.hs +++ b/src/Game/Entities/Slime.hs @@ -1,14 +1,13 @@ module Game.Entities.Slime (mkSlime) where import Data.Bits (Bits (..)) -import Data.IORef import Game.Entities.Common import Game.Entities.Const import Game.Entities.Types import qualified Game.Sprites as S -mkSlime :: S.SpriteSheet -> Int -> Int -> IORef Entity -> IsBlocked -> IO () -> IO Entity -mkSlime sprites x y playerRef isBlocked hitPlayer' = do +mkSlime :: S.SpriteSheet -> Int -> Int -> Collision -> IsBlocked -> IO () -> IO Entity +mkSlime sprites x y playerCollision isBlocked hitPlayer' = do s <- S.get sprites "slime" pure Entity @@ -21,7 +20,7 @@ mkSlime sprites x y playerRef isBlocked hitPlayer' = do gravity = gravityOff, dir = DirRight, sprite = s, - update = updateSlime (collision playerRef 16) isBlocked hitPlayer', + update = updateSlime playerCollision isBlocked hitPlayer', destroy = False, spawns = [] } |