From ed585355b1f78de15885e803138a98b75ca2b1e2 Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Mon, 20 Feb 2023 21:52:22 +0000 Subject: Split entities in modules. --- src/Game/Entities/Effect.hs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/Game/Entities/Effect.hs (limited to 'src/Game/Entities/Effect.hs') diff --git a/src/Game/Entities/Effect.hs b/src/Game/Entities/Effect.hs new file mode 100644 index 0000000..0a20445 --- /dev/null +++ b/src/Game/Entities/Effect.hs @@ -0,0 +1,31 @@ +module Game.Entities.Effect (mkEffect) where + +import Game.Entities.Common +import Game.Entities.Const +import Game.Entities.Types +import qualified Game.Sprites as S + +mkEffect :: S.SpriteSheet -> Int -> Int -> String -> IO Entity +mkEffect sprites x y name = do + s <- S.get sprites name + pure + Entity + { typ = TypeEffect, + x = x, + y = y, + delay = frameDelay, + frame = 0, + jumping = False, + gravity = gravityOff, + dir = DirRight, + sprite = s, + update = pure . updateEffect, + destroy = False, + spawns = [] + } + +updateEffect :: Entity -> Entity +updateEffect e + | e.delay > 0 = e {delay = e.delay - 1} + | e.frame + 1 < frameLimit e = e {delay = frameDelay, frame = e.frame + 1} + | otherwise = e {destroy = True} -- cgit v1.2.3