Safe Haskell | None |
---|---|
Language | Haskell2010 |
- type Seconds = Float
- type DeltaSeconds = Seconds
- type Color = (Word8, Word8, Word8)
- type FrameIndex = Int
- data Frame loc = Frame loc Seconds
- data Animations key loc
- data Loop
- data Position key = Position key FrameIndex Seconds Loop
- data FrameStep
- class (Ord key, Bounded key, Enum key) => Key key
- class Key key => KeyName key where
- data SpriteClip = SpriteClip Int Int Int Int (Maybe (Int, Int))
- data SpriteSheet key img = SpriteSheet (Animations key SpriteClip) img
- data SpriteSheetInfo = SpriteSheetInfo FilePath (Maybe Color) [SpriteClip] (Map Text [(FrameIndex, Seconds)])
- animations :: Key key => (key -> [Frame loc]) -> Animations key loc
- framesByAnimation :: Key key => Animations key loc -> key -> Vector (Frame loc)
- initPosition :: Key key => key -> Position key
- initPositionLoops :: Key key => key -> Int -> Position key
- initPositionWithLoop :: Key key => key -> Loop -> Position key
- stepFrame :: Frame loc -> Position key -> DeltaSeconds -> FrameStep
- stepPosition :: Key key => Animations key loc -> Position key -> DeltaSeconds -> Position key
- isAnimationComplete :: Key key => Animations key loc -> Position key -> Bool
- positionHasLooped :: Position key -> Position a -> Bool
- currentFrame :: Key key => Animations key loc -> Position key -> Frame loc
- currentLocation :: Key key => Animations key loc -> Position key -> loc
- nextKey :: Key key => key -> key
- prevKey :: Key key => key -> key
- readSpriteSheetInfoJSON :: FilePath -> IO SpriteSheetInfo
- readSpriteSheetJSON :: KeyName key => (FilePath -> Maybe Color -> IO img) -> FilePath -> IO (SpriteSheet key img)
Documentation
type DeltaSeconds = Seconds Source #
Type aliased seconds
type FrameIndex = Int Source #
data Animations key loc Source #
Eq loc => Eq (Animations key loc) Source # | |
Show loc => Show (Animations key loc) Source # | |
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. |
State for progression through an animation
| `example = Position minBound 0 0 LoopAlways
You can ignore. An intermediate type for stepPosition
to judge how to increment the current frame.
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. |
class (Ord key, Bounded key, Enum key) => Key key Source #
Sematically for an animation key constraint
data SpriteClip Source #
Describe the boxed area of the 2d sprite inside a sprite sheet
data SpriteSheet key img Source #
Generalized sprite sheet data structure
SpriteSheet (Animations key SpriteClip) img |
data SpriteSheetInfo Source #
One way to represent sprite sheet information. | JSON loading is included.
SpriteSheetInfo FilePath (Maybe Color) [SpriteClip] (Map Text [(FrameIndex, Seconds)]) |
animations :: Key key => (key -> [Frame loc]) -> Animations key loc Source #
Generate animations given each constructor
framesByAnimation :: Key key => Animations key loc -> key -> Vector (Frame loc) Source #
Lookup the frames of an animation
initPosition :: Key key => key -> Position key Source #
New Position
with its animation key to loop forever
initPositionLoops :: Key key => key -> Int -> Position key Source #
New Position
with its animation key with a limited loop
stepFrame :: Frame loc -> Position key -> DeltaSeconds -> FrameStep Source #
Intermediate function for how a frame should be step through.
stepPosition :: Key key => Animations key loc -> Position key -> DeltaSeconds -> Position key Source #
Step through the animation resulting a new position.
isAnimationComplete :: Key key => Animations key loc -> Position key -> 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 :: Key key => Animations key loc -> Position key -> Frame loc Source #
Use the position to find the current frame of the animation.
currentLocation :: Key key => Animations key loc -> Position key -> loc Source #
Use the position to find the current location, lik a sprite sheet clip, of the animation.
readSpriteSheetInfoJSON Source #
:: FilePath | Path of the sprite sheet info JSON file |
-> IO SpriteSheetInfo |
Quick function for loading SpriteSheetInfo
.
| Check the example.
:: KeyName key | |
=> (FilePath -> Maybe Color -> IO img) | Inject animage loading function |
-> FilePath | Path of the sprite sheet info JSON file |
-> IO (SpriteSheet key img) |
Quick function for loading SpriteSheetInfo
, then using it to load its image for a SpriteSheet
| Check the example.