new version with more features
This commit is contained in:
parent
29183fb223
commit
8c1d5a2664
6 changed files with 40 additions and 4 deletions
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
18
src/Affection/MouseInteractable.hs
Normal file
18
src/Affection/MouseInteractable.hs
Normal 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 ()
|
14
src/Affection/StateMachine.hs
Normal file
14
src/Affection/StateMachine.hs
Normal 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 ()
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue