Add display to pause screen
This commit is contained in:
parent
a6a70e5dca
commit
35e68719cb
|
@ -20,5 +20,10 @@ getSquare (toEnum -> x, toEnum -> y) =
|
||||||
|
|
||||||
displayState :: Monad m => MSF (DrawerT m) GameState ()
|
displayState :: Monad m => MSF (DrawerT m) GameState ()
|
||||||
displayState = proc state -> do
|
displayState = proc state -> do
|
||||||
draw -< mconcat $ color green . getSquare <$> state.snakePos
|
draw -< pictures $ color green . getSquare <$> state.snakePos
|
||||||
draw -< color red $ getSquare state.berryPos
|
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"
|
||||||
|
|
|
@ -83,8 +83,11 @@ mainSF = proc () -> do
|
||||||
keys <- getKeys -< ()
|
keys <- getKeys -< ()
|
||||||
let esc = SpecialKey KeyEsc `elem` keys
|
let esc = SpecialKey KeyEsc `elem` keys
|
||||||
|
|
||||||
paused <- accumulateWith xor True -< esc
|
unpaused <- accumulateWith xor True -< esc
|
||||||
state <- pauseMSF undefined (loopMaybe gameSF) -< ((), paused)
|
state <- pauseMSF undefined (loopMaybe gameSF) -< ((), unpaused)
|
||||||
|
|
||||||
-- Display the current state
|
-- Display the current state
|
||||||
displayState -< state
|
displayState -< state
|
||||||
|
if unpaused
|
||||||
|
then returnA -< ()
|
||||||
|
else displayPause -< ()
|
||||||
|
|
Loading…
Reference in a new issue