32 lines
914 B
Haskell
32 lines
914 B
Haskell
-- Input for RPG-Engine
|
|
|
|
module RPGEngine.Input
|
|
( handleAllInput
|
|
) where
|
|
|
|
import RPGEngine.Internals.Data.Game
|
|
import RPGEngine.Internals.Data.State
|
|
import RPGEngine.Internals.Input
|
|
|
|
import Graphics.Gloss.Interface.IO.Game
|
|
|
|
----------------------------------------------------------------------
|
|
|
|
-- Handle all input for RPG-Engine
|
|
handleAllInput :: InputHandler Game
|
|
handleAllInput ev g@Game{ state = Playing } = handlePlayInputs ev g
|
|
handleAllInput ev g = handleAnyKey setNextState ev g
|
|
|
|
----------------------------------------------------------------------
|
|
|
|
-- Input for 'Playing' state
|
|
handlePlayInputs :: InputHandler Game
|
|
handlePlayInputs = composeInputHandlers [
|
|
handleKey (Char 'p') (\game -> game{ state = Pause })
|
|
]
|
|
|
|
-- Go to the next stage of the Game
|
|
setNextState :: Game -> Game
|
|
setNextState game = game{ state = newState }
|
|
where newState = nextState $ state game
|
|
|