#18 & massive structure overhaul

This commit is contained in:
Tibo De Peuter 2022-12-19 22:54:42 +01:00
parent 83659e69b4
commit 3b0de65de1
16 changed files with 397 additions and 221 deletions

32
lib/RPGEngine/Input.hs Normal file
View file

@ -0,0 +1,32 @@
-- 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