Add display to pause screen

This commit is contained in:
Kiana Sheibani 2024-04-22 22:41:39 -04:00
parent a6a70e5dca
commit 35e68719cb
Signed by: toki
GPG key ID: 6CB106C25E86A9F7
2 changed files with 11 additions and 3 deletions

View file

@ -20,5 +20,10 @@ getSquare (toEnum -> x, toEnum -> y) =
displayState :: Monad m => MSF (DrawerT m) GameState ()
displayState = proc state -> do
draw -< mconcat $ color green . getSquare <$> state.snakePos
draw -< pictures $ color green . getSquare <$> state.snakePos
draw -< color red $ getSquare state.berryPos
displayPause :: Monad m => MSF (DrawerT m) () ()
displayPause = proc () -> do
draw -< color (withAlpha 0.5 black) $ rectangleSolid 5000 5000
draw -< color white $ scale 0.5 0.5 $ text "Paused"

View file

@ -83,8 +83,11 @@ mainSF = proc () -> do
keys <- getKeys -< ()
let esc = SpecialKey KeyEsc `elem` keys
paused <- accumulateWith xor True -< esc
state <- pauseMSF undefined (loopMaybe gameSF) -< ((), paused)
unpaused <- accumulateWith xor True -< esc
state <- pauseMSF undefined (loopMaybe gameSF) -< ((), unpaused)
-- Display the current state
displayState -< state
if unpaused
then returnA -< ()
else displayPause -< ()