animate-0.1.0: Animation for sprites

Safe HaskellNone
LanguageHaskell2010

Data.Animate

Synopsis

Documentation

type Seconds = Float Source #

Avoided newtype wrapper for convenience (tentative)

type DeltaSeconds = Seconds Source #

Type aliased seconds (tentative)

data Frame loc Source #

Constructors

Frame loc Seconds 

Instances

Eq loc => Eq (Frame loc) Source # 

Methods

(==) :: Frame loc -> Frame loc -> Bool #

(/=) :: Frame loc -> Frame loc -> Bool #

Show loc => Show (Frame loc) Source # 

Methods

showsPrec :: Int -> Frame loc -> ShowS #

show :: Frame loc -> String #

showList :: [Frame loc] -> ShowS #

data Animations a loc Source #

Type safe animation set. Use an sum type with an Enum and Bounded instance for the animation, a.

Instances

Eq loc => Eq (Animations a loc) Source # 

Methods

(==) :: Animations a loc -> Animations a loc -> Bool #

(/=) :: Animations a loc -> Animations a loc -> Bool #

Show loc => Show (Animations a loc) Source # 

Methods

showsPrec :: Int -> Animations a loc -> ShowS #

show :: Animations a loc -> String #

showList :: [Animations a loc] -> ShowS #

animations :: (Enum a, Bounded a) => (a -> [Frame loc]) -> Animations a loc Source #

Generate animations given each constructor

framesByAnimation :: Enum a => Animations a loc -> a -> Vector (Frame loc) Source #

Lookup the frames of an animation

data Loop Source #

Constructors

Loop'Forever

Never stop looping. Animation can never be completed.

Loop'Count Int

Count down loops to below zero. 0 = no loop. 1 = one loop. 2 = two loops. etc.

Instances

Eq Loop Source # 

Methods

(==) :: Loop -> Loop -> Bool #

(/=) :: Loop -> Loop -> Bool #

Show Loop Source # 

Methods

showsPrec :: Int -> Loop -> ShowS #

show :: Loop -> String #

showList :: [Loop] -> ShowS #

data Position a Source #

State for progression through an animation

Constructors

Position a Int Seconds Loop 

Instances

Eq a => Eq (Position a) Source # 

Methods

(==) :: Position a -> Position a -> Bool #

(/=) :: Position a -> Position a -> Bool #

Show a => Show (Position a) Source # 

Methods

showsPrec :: Int -> Position a -> ShowS #

show :: Position a -> String #

showList :: [Position a] -> ShowS #

data FrameStep Source #

You can ignore. An intermediate type for stepAnimation to judge how to increment the current frame.

Constructors

FrameStep'Counter Seconds

New counter to compare against the frame's delay.

FrameStep'Delta DeltaSeconds

How much delta to carry over into the next frame.

stepFrame :: Frame loc -> Position a -> DeltaSeconds -> FrameStep Source #

Intermediate function for how a frame should be step through.

stepAnimation :: Enum a => Animations a loc -> Position a -> DeltaSeconds -> Position a Source #

Step through the animation resulting in a new position.

isAnimationComplete :: Enum a => Animations a loc -> Position a -> Bool Source #

The animation has finished all its frames. Useful for signalling into switching to another animation. With a Loop'Forever, the animation will never be completed.

positionHasLooped Source #

Arguments

:: Position a

Previous

-> Position a

Next

-> Bool 

Simple function diff'ing the position for loop change (tentative)