| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Animate
- type Color = (Word8, Word8, Word8)
- type FrameIndex = Int
- data Frame loc delay = Frame {}
- newtype Animations key loc delay = Animations {
- unAnimations :: Vector (Vector (Frame loc delay))
- data Loop
- data Position key delay = Position {
- pKey :: key
- pFrameIndex :: FrameIndex
- pCounter :: delay
- pLoop :: Loop
- data FrameStep delay
- = FrameStep'Counter delay
- | FrameStep'Delta delay
- class KeyName key where
- data SpriteClip key = SpriteClip {}
- data SpriteSheet key img delay = SpriteSheet {
- ssAnimations :: Animations key (SpriteClip key) delay
- ssImage :: img
- data SpriteSheetInfo key delay = SpriteSheetInfo {
- ssiImage :: FilePath
- ssiAlpha :: Maybe Color
- ssiClips :: [SpriteClip key]
- ssiAnimations :: Map Text [(FrameIndex, delay)]
- animations :: (Enum key, Bounded key) => (key -> [Frame loc delay]) -> Animations key loc delay
- framesByAnimation :: Enum key => Animations key loc delay -> key -> Vector (Frame loc delay)
- initPosition :: Num delay => key -> Position key delay
- initPositionLoops :: Num delay => key -> Int -> Position key delay
- initPositionWithLoop :: Num delay => key -> Loop -> Position key delay
- stepFrame :: (Num delay, Ord delay) => Frame loc delay -> Position key delay -> delay -> FrameStep delay
- stepPosition :: (Enum key, Num delay, Ord delay) => Animations key loc delay -> Position key delay -> delay -> Position key delay
- isAnimationComplete :: (Enum key, Num delay, Ord delay) => Animations key loc delay -> Position key delay -> Bool
- positionHasLooped :: Position key delay -> Position key delay -> Bool
- currentFrame :: (Enum key, Num delay) => Animations key loc delay -> Position key delay -> Frame loc delay
- currentLocation :: (Enum key, Num delay) => Animations key loc delay -> Position key delay -> loc
- nextKey :: (Bounded key, Enum key, Eq key) => key -> key
- prevKey :: (Bounded key, Enum key, Eq key) => key -> key
- readSpriteSheetInfoJSON :: FromJSON delay => FilePath -> IO (SpriteSheetInfo key delay)
- readSpriteSheetInfoYAML :: FromJSON delay => FilePath -> IO (SpriteSheetInfo key delay)
- readSpriteSheetJSON :: (KeyName key, Ord key, Bounded key, Enum key, FromJSON delay) => (FilePath -> Maybe Color -> IO img) -> FilePath -> IO (SpriteSheet key img delay)
- readSpriteSheetYAML :: (KeyName key, Ord key, Bounded key, Enum key, FromJSON delay) => (FilePath -> Maybe Color -> IO img) -> FilePath -> IO (SpriteSheet key img delay)
Documentation
type FrameIndex = Int Source #
Constructors
| Frame | |
newtype Animations key loc delay Source #
Constructors
| Animations | |
Fields
| |
Constructors
| Loop'Always | 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. |
data Position key delay Source #
State for progression through an animation
example = Position minBound 0 0 Loop'Always
Constructors
| Position | |
Fields
| |
You can ignore. An intermediate type for stepPosition to judge how to increment the current frame.
Constructors
| FrameStep'Counter delay | New counter to compare against the frame's delay. |
| FrameStep'Delta delay | How much delta to carry over into the next frame. |
data SpriteClip key Source #
Describe the boxed area of the 2d sprite inside a sprite sheet
Constructors
| SpriteClip | |
Instances
| Eq (SpriteClip key) Source # | |
| Show (SpriteClip key) Source # | |
| Generic (SpriteClip key) Source # | |
| ToJSON (SpriteClip key) Source # | |
| FromJSON (SpriteClip key) Source # | |
| type Rep (SpriteClip key) Source # | |
data SpriteSheet key img delay Source #
Generalized sprite sheet data structure
Constructors
| SpriteSheet | |
Fields
| |
Instances
| Generic (SpriteSheet key img delay) Source # | |
| type Rep (SpriteSheet key img delay) Source # | |
data SpriteSheetInfo key delay Source #
One way to represent sprite sheet information. JSON loading is included.
Constructors
| SpriteSheetInfo | |
Fields
| |
Instances
| Eq delay => Eq (SpriteSheetInfo key delay) Source # | |
| Show delay => Show (SpriteSheetInfo key delay) Source # | |
| Generic (SpriteSheetInfo key delay) Source # | |
| ToJSON delay => ToJSON (SpriteSheetInfo key delay) Source # | |
| FromJSON delay => FromJSON (SpriteSheetInfo key delay) Source # | |
| type Rep (SpriteSheetInfo key delay) Source # | |
animations :: (Enum key, Bounded key) => (key -> [Frame loc delay]) -> Animations key loc delay Source #
Generate animations given each constructor
framesByAnimation :: Enum key => Animations key loc delay -> key -> Vector (Frame loc delay) Source #
Lookup the frames of an animation
initPosition :: Num delay => key -> Position key delay Source #
New Position with its animation key to loop forever
initPositionLoops :: Num delay => key -> Int -> Position key delay Source #
New Position with its animation key with a limited loop
stepFrame :: (Num delay, Ord delay) => Frame loc delay -> Position key delay -> delay -> FrameStep delay Source #
Intermediate function for how a frame should be step through.
stepPosition :: (Enum key, Num delay, Ord delay) => Animations key loc delay -> Position key delay -> delay -> Position key delay Source #
Step through the animation resulting a new position.
isAnimationComplete :: (Enum key, Num delay, Ord delay) => Animations key loc delay -> Position key delay -> Bool Source #
The animation has finished all its frames. Useful for signalling into switching to another animation. With a Loop'Always, the animation will never be completed.
Simple function diff'ing the position for loop change.
currentFrame :: (Enum key, Num delay) => Animations key loc delay -> Position key delay -> Frame loc delay Source #
Use the position to find the current frame of the animation.
currentLocation :: (Enum key, Num delay) => Animations key loc delay -> Position key delay -> loc Source #
Use the position to find the current location, lik a sprite sheet clip, of the animation.
nextKey :: (Bounded key, Enum key, Eq key) => key -> key Source #
Cycle through the next animation key.
prevKey :: (Bounded key, Enum key, Eq key) => key -> key Source #
Cycle through the previous animation key.
readSpriteSheetInfoJSON Source #
Arguments
| :: FromJSON delay | |
| => FilePath | Path of the sprite sheet info JSON file |
| -> IO (SpriteSheetInfo key delay) |
Quick function for loading SpriteSheetInfo.
Check the example.
readSpriteSheetInfoYAML Source #
Arguments
| :: FromJSON delay | |
| => FilePath | Path of the sprite sheet info JSON file |
| -> IO (SpriteSheetInfo key delay) |
Arguments
| :: (KeyName key, Ord key, Bounded key, Enum key, FromJSON delay) | |
| => (FilePath -> Maybe Color -> IO img) | Inject an image loading function |
| -> FilePath | Path of the sprite sheet info JSON file |
| -> IO (SpriteSheet key img delay) |
Quick function for loading SpriteSheetInfo, then using it to load its image for a SpriteSheet.
Check the example.