#15 Input handling made modular

This commit is contained in:
Tibo De Peuter 2022-12-15 10:22:30 +01:00
parent 30ae002434
commit 0257bb8220
2 changed files with 28 additions and 10 deletions

View file

@ -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