-------------------------------------------------------------------------------
-- Animation
-- 2018 Francesco Ariis GPLv3
-------------------------------------------------------------------------------

-- {-# LANGUAGE DeriveGeneric #-}
-- {-# LANGUAGE DefaultSignatures #-}
-- {-# LANGUAGE StandaloneDeriving #-}
-- {-# LANGUAGE FlexibleInstances #-}

module Terminal.Game.Animation (module Terminal.Game.Animation,
                                module T
                               ) where

import Terminal.Game.Plane

import Control.Timer.Tick as T

-- import Data.Serialize

-- import qualified Data.ByteString as BS
-- import qualified Data.Bifunctor as BF

-- | An @Animation@ is a series of timed time-separated 'Plane's.
type Animation = T.Timed Plane

-- | Creates an 'Animation'.
creaAnimation :: [(Integer, Plane)] -> Animation
creaAnimation :: [(Integer, Plane)] -> Animation
creaAnimation [(Integer, Plane)]
ips = Loop -> [(Integer, Plane)] -> Animation
forall a. Loop -> [(Integer, a)] -> Timed a
creaTimedRes (Integer -> ExpBehaviour -> Loop
Times Integer
1 ExpBehaviour
Elapse) [(Integer, Plane)]
ips

-- | Creates a looped 'Animation'.
creaLoopAnimation :: [(Integer, Plane)] -> Animation
creaLoopAnimation :: [(Integer, Plane)] -> Animation
creaLoopAnimation [(Integer, Plane)]
ips = Loop -> [(Integer, Plane)] -> Animation
forall a. Loop -> [(Integer, a)] -> Timed a
creaTimedRes Loop
AlwaysLoop [(Integer, Plane)]
ips

-- | Wraps a 'Plane' into an 'Animation'.
creaStaticAnimation :: Plane -> Animation
creaStaticAnimation :: Plane -> Animation
creaStaticAnimation Plane
p = Loop -> [(Integer, Plane)] -> Animation
forall a. Loop -> [(Integer, a)] -> Timed a
creaTimedRes (Integer -> ExpBehaviour -> Loop
Times Integer
1 ExpBehaviour
Elapse) [(Integer
1, Plane
p)]