Reformat Graphics.Engine
This commit is contained in:
parent
a53e0204c0
commit
156a338d48
|
@ -1,3 +1,4 @@
|
|||
{-# LANGUAGE LambdaCase #-}
|
||||
module Graphics.Engine where
|
||||
|
||||
import Control.Arrow
|
||||
|
@ -5,13 +6,26 @@ import Control.Monad.Representable.Reader
|
|||
import FRP.Yampa
|
||||
import GOL.Engine
|
||||
import GOL.Space
|
||||
import Graphics.Config
|
||||
import Graphics.Gloss
|
||||
import Graphics.GlossUtils (InputEvent)
|
||||
import Graphics.Gloss.Interface.IO.Game hiding (Event)
|
||||
import qualified Graphics.Gloss.Interface.IO.Game as G
|
||||
|
||||
tickEvent :: SF a (Event ())
|
||||
tickEvent = repeatedly 1.0 ()
|
||||
data Tick = Tick
|
||||
|
||||
initialSpace :: Space f => f Bool
|
||||
initialSpace = tabulate $ const False
|
||||
|
||||
engine :: Space f => GOL f Bool -> SF a (GOL f Bool)
|
||||
engine start = tickEvent >>> accumHoldBy (\s _ -> tick s) start
|
||||
engine :: Space f => GOL f Bool -> SF (Event Tick) (GOL f Bool)
|
||||
engine = accumHoldBy (\s _ -> tick s)
|
||||
|
||||
defaultPeriod = 0.5
|
||||
|
||||
repeatTick :: Time -> SF a (Event Tick)
|
||||
repeatTick t = repeatedly t Tick
|
||||
|
||||
tickSignal :: SF (Event Time) (Event Tick)
|
||||
tickSignal =
|
||||
arr (\ev -> ((), fmap repeatTick ev))
|
||||
>>> drSwitch (repeatTick defaultPeriod)
|
||||
|
|
Loading…
Reference in a new issue