-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A simple Game Engine using SDL -- -- This package contains Affection, a simple game engine written in -- Haskell using SDL and GEGL. This Engine is still work in progress and -- even minor version bumps may contain breaking api changes. @package affection @version 0.0.0.3 module Affection.Types type Affection us a = AffectionState (AffectionData us) IO a -- | Main type for defining the look, feel and action of the whole -- application. data AffectionData us AffectionData :: Bool -> us -> Window -> Surface -> Surface -> BablFormatPtr -> [DrawRequest] -> Ptr () -> (Int, Int) -> Int -> Int -> Double -> AffectionData us -- | Loop breaker. [quitEvent] :: AffectionData us -> Bool -- | State data provided by user [userState] :: AffectionData us -> us -- | SDL window [drawWindow] :: AffectionData us -> Window -- | Internal surface of window [windowSurface] :: AffectionData us -> Surface -- | SDL surface [drawSurface] :: AffectionData us -> Surface -- | Target format [drawFormat] :: AffectionData us -> BablFormatPtr -- | Stack of DrawRequests to be processed [drawStack] :: AffectionData us -> [DrawRequest] -- | Destination Pixel buffer [drawPixels] :: AffectionData us -> Ptr () -- | Dimensions of target surface [drawDimensions] :: AffectionData us -> (Int, Int) -- | Stride of target buffer [drawStride] :: AffectionData us -> Int -- | Number of components per pixel [drawCPP] :: AffectionData us -> Int -- | Elapsed time in seconds [elapsedTime] :: AffectionData us -> Double -- | Configuration for the aplication. needed at startup. data AffectionConfig us AffectionConfig :: InitComponents -> Text -> WindowConfig -> Affection us () -> Affection us () -> (Double -> [Event] -> Affection us ()) -> (Surface -> IO us) -> (us -> IO ()) -> AffectionConfig us -- | SDL components to initialize at startup [initComponents] :: AffectionConfig us -> InitComponents -- | Window title [windowTitle] :: AffectionConfig us -> Text -- | Window configuration [windowConfig] :: AffectionConfig us -> WindowConfig -- | Actions to be performed, before loop starts [preLoop] :: AffectionConfig us -> Affection us () -- | Function for updating graphics. [drawLoop] :: AffectionConfig us -> Affection us () -- | Main update function. Takes fractions of a second as input. [updateLoop] :: AffectionConfig us -> Double -> [Event] -> Affection us () -- | Provide your own load function to create this data. [loadState] :: AffectionConfig us -> Surface -> IO us -- | Provide your own finisher function to clean your data. [cleanUp] :: AffectionConfig us -> us -> IO () -- | Affection's state monad newtype AffectionState us m a AffectionState :: AffectionStateInner us m a -> AffectionState us m a [runState] :: AffectionState us m a -> AffectionStateInner us m a -- | Inner StateT monad for the update state type -- AffectionStateInner us m a = StateT (AffectionData us) m a type AffectionStateInner us m a = StateT us m a -- | Components to initialize in SDL. data InitComponents All :: InitComponents Only :: [InitFlag] -> InitComponents data RGBA RGBA :: Int -> Int -> Int -> Int -> RGBA [r] :: RGBA -> Int [g] :: RGBA -> Int [b] :: RGBA -> Int [a] :: RGBA -> Int -- | Type for defining the draw type of draw functions data DrawType -- | Fill the specified area completely with color Fill :: DrawType -- | only draw the outline of the area Line :: Int -> DrawType -- | Width of line in pixels [lineWidth] :: DrawType -> Int -- | This datatype stores information about areas of a GeglBuffer to -- be updated data DrawRequest DrawRequest :: GeglRectangle -> GeglBuffer -> RequestPersist -> DrawRequest -- | The area to update [requestArea] :: DrawRequest -> GeglRectangle -- | Buffer to draw [requestBuffer] :: DrawRequest -> GeglBuffer -- | Shall the drawRequest persist [requestPersist] :: DrawRequest -> RequestPersist data RequestPersist Yes :: RequestPersist Kill :: (Maybe GeglNode) -> RequestPersist -- | Type for defining angles data Angle -- | Angle in radians Rad :: Double -> Angle -- | Angle in degrees Deg :: Double -> Angle -- | Typeclass for converting Angles from Deg to Rad and vice -- versa. class ConvertAngle a toRad :: ConvertAngle a => a -> a toDeg :: ConvertAngle a => a -> a -- | A single particle data Particle Particle :: Double -> Double -> (Double, Double) -> Angle -> (Int, Int) -> Angle -> GeglNode -> Map String GeglNode -> GeglNode -> GeglNode -> Particle -- | Time to live in seconds [particleTimeToLive] :: Particle -> Double -- | Creation time of particle in seconds form program start [particleCreation] :: Particle -> Double -- | Position of particle on canvas [particlePosition] :: Particle -> (Double, Double) -- | Particle rotation [particleRotation] :: Particle -> Angle -- | particle velocity as vector of pixels per second [particleVelocity] :: Particle -> (Int, Int) -- | Rotational velocity of particle in angle per second [particlePitchRate] :: Particle -> Angle -- | Root GeglNode of Particle [particleRootNode] :: Particle -> GeglNode -- | Node Graph of GeglNodes per particle [particleNodeGraph] :: Particle -> Map String GeglNode -- | GeglNode to connect other Particles to [particleStackCont] :: Particle -> GeglNode -- | GeglNode to connect draw actions to [particleDrawFlange] :: Particle -> GeglNode -- | The particle system data ParticleSystem ParticleSystem :: ParticleStorage -> GeglNode -> GeglBuffer -> ParticleSystem [partSysParts] :: ParticleSystem -> ParticleStorage [partSysNode] :: ParticleSystem -> GeglNode [partSysBuffer] :: ParticleSystem -> GeglBuffer -- | The particle storage datatype data ParticleStorage ParticleStorage :: Maybe Particle -> [Particle] -> ParticleStorage -- | The particle stored last [partStorLatest] :: ParticleStorage -> Maybe Particle -- | List of particles in ascending order of remaining lifetime [partStorList] :: ParticleStorage -> [Particle] liftIO :: MonadIO m => forall a. IO a -> m a data WindowConfig :: * WindowConfig :: Bool -> Bool -> Bool -> WindowMode -> Maybe OpenGLConfig -> WindowPosition -> Bool -> V2 CInt -> WindowConfig [windowBorder] :: WindowConfig -> Bool [windowHighDPI] :: WindowConfig -> Bool [windowInputGrabbed] :: WindowConfig -> Bool [windowMode] :: WindowConfig -> WindowMode [windowOpenGL] :: WindowConfig -> Maybe OpenGLConfig [windowPosition] :: WindowConfig -> WindowPosition [windowResizable] :: WindowConfig -> Bool [windowInitialSize] :: WindowConfig -> V2 CInt defaultWindow :: WindowConfig data GeglRectangle :: * GeglRectangle :: Int -> Int -> Int -> Int -> GeglRectangle [rectangleX] :: GeglRectangle -> Int [rectangleY] :: GeglRectangle -> Int [rectangleWidth] :: GeglRectangle -> Int [rectangleHeight] :: GeglRectangle -> Int data GeglBuffer :: * GeglBuffer :: GeglBufferDummy -> GeglBuffer instance GHC.Classes.Eq Affection.Types.Particle instance GHC.Show.Show Affection.Types.Angle instance GHC.Base.Monad m => Control.Monad.State.Class.MonadState us (Affection.Types.AffectionState us m) instance Control.Monad.IO.Class.MonadIO m => Control.Monad.IO.Class.MonadIO (Affection.Types.AffectionState us m) instance GHC.Base.Monad m => GHC.Base.Monad (Affection.Types.AffectionState us m) instance GHC.Base.Monad m => GHC.Base.Applicative (Affection.Types.AffectionState us m) instance GHC.Base.Functor m => GHC.Base.Functor (Affection.Types.AffectionState us m) instance Affection.Types.ConvertAngle Affection.Types.Angle instance GHC.Classes.Eq Affection.Types.Angle -- | Module for drawing primitives module Affection.Draw drawRect :: GeglNode -> Color -> DrawType -> GeglRectangle -> GeglBuffer -> Affection us () -- | function for handling DrawRequests and updating the output handleDrawRequest :: Ptr a -> Int -> Int -> DrawRequest -> Affection us (Maybe DrawRequest) -- | clear a previously drawn area invalidateDrawRequest :: Ptr a -> Int -> Int -> DrawRequest -> Affection us () -- | Force update of a specific region on screen present :: GeglRectangle -> GeglBuffer -> Bool -> Affection us () -- | Clear a specified area of a buffer from all data clearArea :: GeglBuffer -> GeglRectangle -> IO () -- | This module introduces a simple particle system to Affection module Affection.Particle updateParticle :: Double -> (Double -> Particle -> Affection us Particle) -> Particle -> Affection us (Maybe Particle) drawParticles :: (Particle -> Affection us ()) -> [Particle] -> Affection us () updateParticleSystem :: ParticleSystem -> Double -> (Double -> Particle -> Affection us Particle) -> (GeglBuffer -> GeglNode -> Particle -> Affection us ()) -> Affection us ParticleSystem -- | Function for inserting a new Particle into its -- PartileSystem insertParticle :: ParticleSystem -> Particle -> Affection us ParticleSystem module Affection -- | Main function which bootstraps everything else. withAffection :: AffectionConfig us -> IO () -- | Return the userstate to the user getAffection :: Affection us us -- | Put altered user state back putAffection :: us -> Affection us () -- | block a thread for a specified amount of time delaySec :: Int -> IO () get :: MonadState s m => m s put :: MonadState s m => s -> m ()