new version with more features

This commit is contained in:
nek0 2017-03-05 16:39:37 +01:00
parent 29183fb223
commit 8c1d5a2664
6 changed files with 40 additions and 4 deletions

View File

@ -6,7 +6,7 @@ name: affection
-- PVP summary: +-+------- breaking API changes
-- | | +----- non-breaking API additions
-- | | | +--- code changes with no API change
version: 0.0.0.4
version: 0.0.0.5
synopsis: A simple Game Engine using SDL
description: This package contains Affection, a simple game engine
written in Haskell using SDL and GEGL.
@ -39,6 +39,8 @@ library
, Affection.Draw
, Affection.Particle
, Affection.Types
, Affection.StateMachine
, Affection.MouseInteractable
default-extensions: OverloadedStrings
-- Modules included in this library but not exported.

View File

@ -33,6 +33,8 @@ import Debug.Trace
import Affection.Types as A
import Affection.Draw as A
import Affection.Particle as A
import Affection.StateMachine as A
import Affection.MouseInteractable as A
import qualified BABL as B

View File

@ -61,7 +61,7 @@ present
-> Affection us ()
present rect buf kill = do
ad <- get
let k = if not kill then Kill Nothing else Yes
let k = if not kill then Kill Nothing else Persist
put ad
{ drawStack = (DrawRequest rect buf k) : drawStack ad
}
@ -95,7 +95,7 @@ handleDrawRequest pixels stride cpp dr@DrawRequest{..} = do
-- liftIO $ SDL.updateWindowSurface $ drawWindow ad
) mrealRect
case requestPersist of
Yes ->
Persist ->
return Nothing
Kill _ ->
return $ Just dr

View File

@ -0,0 +1,18 @@
{-# LANGUAGE MultiParamTypeClasses #-}
module Affection.MouseInteractable where
import Affection.Types
-- class MouseHoverable a us where
-- onHover :: a -> Affection us ()
-- | Define a mouse clickable object
class MouseClickable a us where
onClick
:: a -- The object
-> SDL.MouseButton -- The clicked button
-> (Int, Int) -- The coordinates of the click
-> SDL.InputMotion -- The 'SDL.InputMotion' of the click
-> Int -- The number of clicks
-> Affection us ()

View File

@ -0,0 +1,14 @@
{-# LANGUAGE MultiParamTypeClasses #-}
module Affection.StateMachine where
import Affection.Types
import qualified SDL
class StateMachine a us where
smLoad :: a -> Affection us ()
smUpdate :: a -> Double -> Affection us ()
smEvent :: a -> Double -> SDL.Event -> Affection us ()
smDraw :: a -> Affection us ()
smClean :: a -> Affection us ()

View File

@ -96,7 +96,7 @@ data DrawRequest = DrawRequest
}
data RequestPersist
= Yes
= Persist
| Kill (Maybe G.GeglNode)
-- | A type for storing 'DrawRequest' results to be executed frequently. TODO