go back to menu after winning or losing the game

This commit is contained in:
nek0 2017-02-26 02:15:24 +01:00
parent f155e1832b
commit aafbfbbc9f
2 changed files with 10 additions and 7 deletions

View file

@ -125,8 +125,12 @@ drawGame = do
(buffer ud)
True
handleGameEvent :: Double -> SDL.Event -> Affection UserData ()
handleGameEvent sec e = do
handleGameEvent
:: Affection UserData ()
-> Double
-> SDL.Event
-> Affection UserData ()
handleGameEvent menuload sec e = do
ad <- get
wd <- getAffection
case SDL.eventPayload e of
@ -206,11 +210,10 @@ handleGameEvent sec e = do
, pixelSize = 8
}
SDL.KeycodeR ->
when (SDL.keyboardEventKeyMotion dat == SDL.Pressed) $ do
when (SDL.keyboardEventKeyMotion dat == SDL.Pressed && wonlost wd) $ do
liftIO $ traceIO "reloading"
liftIO $ clean wd
nd <- liftIO $ load $ drawSurface ad
putAffection nd
-- liftIO $ clean wd
menuload
_ -> return ()
SDL.WindowClosedEvent _ -> do
traceM "seeya!"

View file

@ -92,7 +92,7 @@ instance StateMachine State UserData where
}
_ -> return ()
smEvent InGame sec e = handleGameEvent sec e
smEvent InGame sec e = handleGameEvent (smLoad Menu) sec e
smDraw Menu = do
ud <- getAffection