#15 Input handling made modular
This commit is contained in:
parent
30ae002434
commit
0257bb8220
2 changed files with 28 additions and 10 deletions
|
@ -13,8 +13,12 @@ import Graphics.Gloss.Interface.IO.Game
|
|||
----------------------------------------------------------------------
|
||||
|
||||
handleAllInput :: InputHandler Game
|
||||
handleAllInput = composeInputHandlers [
|
||||
handleSpecialKey KeySpace setNextState
|
||||
handleAllInput ev g@Game{ state = Playing } = handlePlayInputs ev g
|
||||
handleAllInput ev g = handleAnyKey setNextState ev g
|
||||
|
||||
handlePlayInputs :: InputHandler Game
|
||||
handlePlayInputs = composeInputHandlers [
|
||||
handleKey (Char 'p') (\game -> game{ state = Pause })
|
||||
]
|
||||
|
||||
-- Go to the next stage of the Game
|
||||
|
|
Reference in a new issue