go back to menu after winning or losing the game
This commit is contained in:
parent
f155e1832b
commit
aafbfbbc9f
2 changed files with 10 additions and 7 deletions
|
@ -125,8 +125,12 @@ drawGame = do
|
||||||
(buffer ud)
|
(buffer ud)
|
||||||
True
|
True
|
||||||
|
|
||||||
handleGameEvent :: Double -> SDL.Event -> Affection UserData ()
|
handleGameEvent
|
||||||
handleGameEvent sec e = do
|
:: Affection UserData ()
|
||||||
|
-> Double
|
||||||
|
-> SDL.Event
|
||||||
|
-> Affection UserData ()
|
||||||
|
handleGameEvent menuload sec e = do
|
||||||
ad <- get
|
ad <- get
|
||||||
wd <- getAffection
|
wd <- getAffection
|
||||||
case SDL.eventPayload e of
|
case SDL.eventPayload e of
|
||||||
|
@ -206,11 +210,10 @@ handleGameEvent sec e = do
|
||||||
, pixelSize = 8
|
, pixelSize = 8
|
||||||
}
|
}
|
||||||
SDL.KeycodeR ->
|
SDL.KeycodeR ->
|
||||||
when (SDL.keyboardEventKeyMotion dat == SDL.Pressed) $ do
|
when (SDL.keyboardEventKeyMotion dat == SDL.Pressed && wonlost wd) $ do
|
||||||
liftIO $ traceIO "reloading"
|
liftIO $ traceIO "reloading"
|
||||||
liftIO $ clean wd
|
-- liftIO $ clean wd
|
||||||
nd <- liftIO $ load $ drawSurface ad
|
menuload
|
||||||
putAffection nd
|
|
||||||
_ -> return ()
|
_ -> return ()
|
||||||
SDL.WindowClosedEvent _ -> do
|
SDL.WindowClosedEvent _ -> do
|
||||||
traceM "seeya!"
|
traceM "seeya!"
|
||||||
|
|
|
@ -92,7 +92,7 @@ instance StateMachine State UserData where
|
||||||
}
|
}
|
||||||
_ -> return ()
|
_ -> return ()
|
||||||
|
|
||||||
smEvent InGame sec e = handleGameEvent sec e
|
smEvent InGame sec e = handleGameEvent (smLoad Menu) sec e
|
||||||
|
|
||||||
smDraw Menu = do
|
smDraw Menu = do
|
||||||
ud <- getAffection
|
ud <- getAffection
|
||||||
|
|
Loading…
Reference in a new issue