module Game.Entities.Entry (mkEntry) where import Game.Entities.Common import Game.Entities.Const import Game.Entities.Types import qualified Game.Sprites as S mkEntry :: S.SpriteSheet -> Int -> Int -> IO Entity mkEntry sprites x y = do s <- S.get sprites "exit" pure Entity { typ = TypePickup, x = x, y = y, delay = frameDelay, frame = 0, jumping = False, gravity = gravityOff, dir = Dying, sprite = s, update = pure . updateEntry, destroy = False, actions = [] } updateEntry :: Entity -> Entity updateEntry 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, actions = [ActionEntryDone]}