packages feed

astrds-0.1: src/Pic.hs

module Pic where

import qualified Data.Map as M

type Dim = (Int, Int)

-- | Simple pic datatype.
data Pic = Pic { picpath :: String 
               , picdim  :: (Int, Int) 
               }
  deriving (Eq,Show)

-- | Simple sprite datatype.
data Sprite a = Sprite { spic    :: Pic 
                       , offsets :: M.Map a Int -- ^ offsets of the pics in the sprite
                       , tiledim :: Dim
                       }

-- | Simple animation datatype
data Animation = Animation { an_sprite      :: Sprite Int
                           , an_description :: Int -> Int -- ^ time to index
                           } 

picToAnimation :: Pic -> Animation
picToAnimation pic@(Pic img dim) = Animation sprite (const 0)
  where 
    sprite = Sprite pic (M.singleton 0 0) dim