3 import Data
.Function
(fix
)
4 import Data
.IORef
(newIORef
, readIORef
, writeIORef
)
6 import Control
.Monad
.State
19 video
<- startVideo
320 240 UseSDL
21 world
<- (loadWorld video
) >>= newIORef
22 quitRef
<- newIORef
False
23 clock
<- mkClock
10 -- use 10ms time quantum (max 100fps)
25 n
<- readNewClockTicks clock
-- blocks until n > 0
27 inputs
<- readRawInput quitRef
29 let (w
',outs
) = runWorld inputs w
-- 1 game step
31 forM_ outs
(execOutput video audio
)
32 readIORef world
>>= renderWorld video
-- one graphics frame
33 done
<- readIORef quitRef