Game.Aff
- Package
- purescript-game
- Repository
- artemisSystem/purescript-game
#AffGame Source
newtype AffGame extra a
An AffGame
is an Aff
that takes a Reducer
as an argument. Can be
constructed from a TemplateAffGame
using mkAffGame
.
Constructors
Instances
Newtype (AffGame extra a) _
Functor (AffGame extra)
Apply (AffGame extra)
Applicative (AffGame extra)
Bind (AffGame extra)
Monad (AffGame extra)
MonadEffect (AffGame extra)
MonadAff (AffGame extra)
MonadRec (AffGame extra)
MonadThrow Error (AffGame extra)
MonadError Error (AffGame extra)
MonadFork Fiber (AffGame extra)
MonadKill Error Fiber (AffGame extra)
MonadBracket Error Fiber (AffGame extra)
Alt (AffGame extra)
Plus (AffGame extra)
(Semigroup a) => Semigroup (AffGame extra a)
(Monoid a) => Monoid (AffGame extra a)
Lazy (AffGame extra a)
Parallel (ParAffGame extra) (AffGame extra)
#ParAffGame Source
newtype ParAffGame extra a
A variant of AffGame
that composes effects in parallel
Instances
Parallel (ParAffGame extra) (AffGame extra)
Newtype (ParAffGame extra a) _
Functor (ParAffGame extra)
Apply (ParAffGame extra)
Applicative (ParAffGame extra)
Alt (ParAffGame extra)
Plus (ParAffGame extra)
(Semigroup a) => Semigroup (ParAffGame extra a)
(Monoid a) => Monoid (ParAffGame extra a)
#simpleAffGame Source
simpleAffGame :: forall a extra. Run (aff :: AFF, effect :: EFFECT | extra) a -> AffGame extra a
Construct a simple AffGame
using a Run
whose effect row includes the
AffGame
's extra
row
#AffGameUpdate Source
type AffGameUpdate extra e s a = GameUpdate extra Req (ExecOut e s a) Unit
#TemplateAffGame Source
type TemplateAffGame extra e s a = { init :: Run (aff :: AFF, effect :: EFFECT) { env :: e, initState :: s }, updates :: Array (AffGameUpdate extra e s a) }
#interpretAffGame Source
interpretAffGame :: forall a s e. Run (ExecOut e s a) Unit -> Run (Interpreted e s) a
#parallelizeAffGame Source
parallelizeAffGame :: forall a s e. Array (Run (Interpreted e s) a) -> Run (Interpreted e s) a
#mkAffGame Source
mkAffGame :: forall a s e extra. TemplateAffGame extra e s a -> AffGame extra a
Make an AffGame
from a TemplateAffGame
#runGameAff Source
runGameAff :: forall a extra. Reducer extra Req -> AffGame extra a -> Aff a
Run an AffGame
in Aff
#onStart Source
onStart :: forall a s e extra. Run (OnStartExecIn e s a extra) Unit -> AffGameUpdate extra e s a
An AffGameUpdate
that runs once when the AffGame
starts
#loopUpdate Source
loopUpdate :: forall b a s e extra. Aff Unit -> Run (LoopExecIn e s a extra) b -> (b -> Run (LoopExecIn e s a extra) b) -> AffGameUpdate extra e s a
Create an AffGameUpdate
that runs in loops, using the Aff Unit
as a
waiting action inbetween
#loopUpdate' Source
loopUpdate' :: forall a s e extra. Aff Unit -> Run (LoopExecIn e s a extra) Unit -> AffGameUpdate extra e s a
Create a simple loop update that runs the same action repeatedly, using
the Aff Unit
as a waiting action inbetween
#matchInterval Source
matchInterval :: forall d a s e extra. Duration d => Aff Unit -> Run (LoopExecIn e s a extra) d -> Run (LoopExecIn e s a extra) Unit -> AffGameUpdate extra e s a
Create a loop that on every iteration (distinguished by the Aff Unit
)
tries to match the interval returned by the first Run
action. It will not
run the second Run
action (the "update") when looping if the given
duration has not passed since the last update was run.
It compensates for
lost time, so that if the duration is a pure (Milliseconds 10.0)
, and
the waiting action alternates between resolving after 12ms and 8ms, when
the update is first run after 12ms, matchInterval
will remember that it
is 2ms behind, and run the update again when the waiting action resolves
after another 8ms. Also, if the waiting action is long enough that 3 times
the returned duration has passed since the last update, it will clear the
accumulated time difference and run the update once. This is so that if
the waiting action takes a lot longer to resolve one time, a bunch of
updates won't pile up and run in quick succession (otherwise, this can
happen if you switch away from a tab when using delayFrame
as your
waiting action, as it will stop updating until the tab becomes active
again).
#FPS Source
newtype FPS
A newtype with a Duration
instance, where the stored number describes an
amount of frames per second. Running fromDuration
will return the amount
of milliseconds a frame will take at that framerate. fromDuration (FPS
0.0)
is Milliseconds 0.0
.
Constructors
Instances
Re-exports from Game
#GameUpdate Source
newtype GameUpdate (extra :: Row Type) (req :: Row Type) (execOut :: Row Type) a
Constructors
GameUpdate (Reducer extra req -> Run execOut a)