Restructuring, #9
This commit is contained in:
parent
2055ef234e
commit
dab6fadad4
41 changed files with 941 additions and 680 deletions
|
@ -1,50 +1,15 @@
|
|||
-- Input for RPG-Engine
|
||||
|
||||
-- Implementations for each state can be found in their respective
|
||||
-- submodules.
|
||||
module RPGEngine.Input
|
||||
( handleAllInput
|
||||
) where
|
||||
|
||||
import RPGEngine.Data
|
||||
import RPGEngine.Data.State
|
||||
import RPGEngine.Input.Core
|
||||
import RPGEngine.Input.Player
|
||||
import RPGEngine.Data
|
||||
|
||||
import Graphics.Gloss.Interface.IO.Game
|
||||
------------------------------ Exported ------------------------------
|
||||
|
||||
----------------------------------------------------------------------
|
||||
|
||||
-- Handle all input for RPG-Engine
|
||||
-- Handle all input of all states of the game.
|
||||
handleAllInput :: InputHandler Game
|
||||
handleAllInput ev g@Game{ state = Playing } = handlePlayInputs ev g
|
||||
handleAllInput ev g@Game{ state = LvlSelect } = handleLvlSelectInput ev g
|
||||
handleAllInput ev g = handleAnyKey setNextState ev g
|
||||
|
||||
----------------------------------------------------------------------
|
||||
|
||||
-- Input for 'Playing' state
|
||||
handlePlayInputs :: InputHandler Game
|
||||
handlePlayInputs = composeInputHandlers [
|
||||
-- Pause the game
|
||||
handleKey (Char 'p') (\game -> game{ state = Pause }),
|
||||
|
||||
-- Player movement
|
||||
handleKey (SpecialKey KeyUp) $ movePlayer North,
|
||||
handleKey (SpecialKey KeyRight) $ movePlayer East,
|
||||
handleKey (SpecialKey KeyDown) $ movePlayer South,
|
||||
handleKey (SpecialKey KeyLeft) $ movePlayer West,
|
||||
|
||||
handleKey (Char 'w') $ movePlayer North,
|
||||
handleKey (Char 'd') $ movePlayer East,
|
||||
handleKey (Char 's') $ movePlayer South,
|
||||
handleKey (Char 'a') $ movePlayer West
|
||||
]
|
||||
|
||||
-- Input for selection a level to load
|
||||
handleLvlSelectInput :: InputHandler Game
|
||||
handleLvlSelectInput = composeInputHandlers []
|
||||
|
||||
-- Go to the next stage of the Game
|
||||
setNextState :: Game -> Game
|
||||
setNextState game = game{ state = newState }
|
||||
where newState = nextState $ state game
|
||||
|
||||
handleAllInput ev g@Game{ state = state } = handleInput ev g
|
||||
where handleInput = inputHandler $ base state
|
Reference in a new issue