2017-01-02 15:22:23 +00:00
|
|
|
{-# LANGUAGE MultiParamTypeClasses #-}
|
|
|
|
|
2016-12-31 16:01:24 +00:00
|
|
|
module Types where
|
|
|
|
|
|
|
|
import Affection
|
|
|
|
import qualified SDL
|
|
|
|
import GEGL
|
|
|
|
import BABL
|
|
|
|
import qualified Data.Map as M
|
|
|
|
|
|
|
|
data UserData = UserData
|
|
|
|
{ nodeGraph :: M.Map NodeKey GeglNode
|
|
|
|
, ship :: Ship
|
|
|
|
, buffer :: GeglBuffer
|
|
|
|
, haskelloids :: [Haskelloid]
|
|
|
|
, shots :: ParticleSystem
|
|
|
|
-- , debris :: ParticleSystem
|
|
|
|
, wonlost :: Bool
|
|
|
|
, pixelSize :: Int
|
2017-01-02 15:22:23 +00:00
|
|
|
, state :: State
|
2017-01-01 21:58:54 +00:00
|
|
|
, fade :: MenuFade
|
2016-12-31 16:01:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
data Ship = Ship
|
|
|
|
{ sPos :: (Double, Double)
|
|
|
|
, sVel :: (Double, Double)
|
|
|
|
, sRot :: Double
|
|
|
|
, sFlange :: GeglNode
|
|
|
|
}
|
|
|
|
|
|
|
|
data Haskelloid = Haskelloid
|
|
|
|
{ hPos :: (Double, Double)
|
|
|
|
, hVel :: (Double, Double)
|
|
|
|
, hRot :: Double
|
|
|
|
, hPitch :: Double
|
|
|
|
, hDiv :: Int
|
|
|
|
, hFlange :: GeglNode
|
|
|
|
, hNodeGraph :: M.Map String GeglNode
|
|
|
|
} deriving (Eq)
|
|
|
|
|
|
|
|
data NodeKey
|
|
|
|
= KeyRoot
|
|
|
|
| KeyTranslate
|
|
|
|
| KeyRotate
|
|
|
|
| KeyShip
|
|
|
|
| KeyPNop
|
|
|
|
| KeyHNop
|
|
|
|
| KeyCrop
|
|
|
|
| KeyShipOver
|
|
|
|
| KeySink
|
|
|
|
| KeyWon
|
|
|
|
| KeyLost
|
|
|
|
| KeyPixelize
|
|
|
|
| KeyFGOver
|
|
|
|
| KeyFGNop
|
2017-01-01 21:58:54 +00:00
|
|
|
| KeyMenuHeading
|
|
|
|
| KeyMenuText
|
|
|
|
| KeyMenuStart
|
|
|
|
| KeyMenuHighscore
|
|
|
|
| KeyMenuOver
|
2016-12-31 16:01:24 +00:00
|
|
|
deriving (Ord, Eq)
|
|
|
|
|
2017-01-02 15:22:23 +00:00
|
|
|
data State
|
2016-12-31 16:01:24 +00:00
|
|
|
= Menu
|
|
|
|
| HighScore
|
|
|
|
| InGame
|
2017-01-01 21:58:54 +00:00
|
|
|
|
2017-01-02 15:22:23 +00:00
|
|
|
class StateMachine a us where
|
|
|
|
load :: a -> Affection us ()
|
|
|
|
update :: a -> Affection us ()
|
|
|
|
draw :: a -> Affection us ()
|
|
|
|
clean :: a -> Affection us ()
|
|
|
|
|
|
|
|
instance StateMachine State UserData where
|
|
|
|
update Menu = return ()
|
|
|
|
|
|
|
|
|
2017-01-01 21:58:54 +00:00
|
|
|
data MenuFade
|
|
|
|
= FadeIn Double
|
|
|
|
| FadeOut Double
|