Write doc comments

This commit is contained in:
Kiana Sheibani 2023-01-25 15:49:49 -05:00
parent 079294e2df
commit c449d1e892
Signed by: toki
GPG key ID: 6CB106C25E86A9F7
2 changed files with 10 additions and 2 deletions

View file

@ -45,10 +45,11 @@ tick =
mainSF :: Monad m => MSF (DrawerT m) () ()
mainSF = proc () -> do
-- A "tick" is each frame that the snake advances
n <- count -< ()
let isTick = n `mod` 20 == 1
let isTick = n `mod` 8 == 1
-- handle inputs (buffer)
-- Handle inputs (buffer)
dirs <- handleEvents -< ()
dir <- fifoGate -< (dirs, isTick)

View file

@ -10,6 +10,11 @@ import Graphics.Gloss.Interface.IO.Game
-- | Display an MSF outputting a picture value as a window using Gloss.
-- Note that the MSF is not passed a real-time clock.
--
-- The MSF is always called at a consistent framerate, regardless of when input
-- events are registered. It is passed a buffered list of all events that
-- occured between the last and current frames, with the first event in the
-- list being the latest.
playMSF :: Display -> Color -> Int -> MSF IO [Event] Picture -> IO ()
playMSF display color freq msf = do
-- `react` doesn't allow inputs or outputs, so we have to use IORefs
@ -52,6 +57,8 @@ hold =
Just x' -> (x', x')
)
-- | Buffers and returns the elements in FIFO order, only allowing elements to
-- shift out whenever the input boolean is true.
fifoGate :: Monad m => MSF m ([a], Bool) (Maybe a)
fifoGate =
mealy