This repository has been archived on 2023-06-24. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
2022FuncProg-project3-RPGEn.../lib/RPGEngine/Render.hs

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