39 lines
No EOL
1.1 KiB
Haskell
39 lines
No EOL
1.1 KiB
Haskell
-- Implementation for each state can be found in their respective
|
|
-- submodules.
|
|
module RPGEngine.Render
|
|
( initWindow
|
|
, initGame
|
|
, render
|
|
) where
|
|
|
|
import RPGEngine.Render.Core ( Renderer(..) )
|
|
|
|
import RPGEngine.Data ( State(..), Game(..), StateBase(..) )
|
|
import Graphics.Gloss ( Display )
|
|
import Graphics.Gloss.Data.Display ( Display(InWindow) )
|
|
import Graphics.Gloss.Data.Picture (Picture)
|
|
import RPGEngine.Data.Default (defaultLevel, defaultPlayer)
|
|
import RPGEngine.Input.Playing (spawnPlayer)
|
|
import RPGEngine.Render.Menu (renderMenu)
|
|
import RPGEngine.Input.Menu (handleInputMenu)
|
|
|
|
----------------------------------------------------------------------
|
|
|
|
-- Initialize a window to play in
|
|
initWindow :: String -> (Int, Int) -> (Int, Int) -> Display
|
|
initWindow = InWindow
|
|
|
|
-- Initialize the game
|
|
initGame :: Game
|
|
initGame = Game {
|
|
state = Menu{ base = StateBase{
|
|
renderer = renderMenu,
|
|
inputHandler = handleInputMenu
|
|
}}
|
|
}
|
|
|
|
-- Render all different states
|
|
render :: Game -> Picture
|
|
render g@Game{ state = state } = renderFunc state
|
|
where stateBase = base state
|
|
renderFunc = renderer stateBase |