93 lines
No EOL
2.6 KiB
Haskell
93 lines
No EOL
2.6 KiB
Haskell
-- Allows to play a game using RPGEngine.
|
|
-- Includes all logic and rendering.
|
|
|
|
module RPGEngine
|
|
( playRPGEngine
|
|
) where
|
|
|
|
import RPGEngine.Config ( bgColor, winDimensions, winOffsets )
|
|
import RPGEngine.Render ( initWindow, render )
|
|
import RPGEngine.Input ( handleAllInput )
|
|
import RPGEngine.Input.Playing ( checkPlaying, spawnPlayer )
|
|
import RPGEngine.Data (Game (..), State (..), Layout, Level (..), Physical (..), Entity(..), Direction(..), Player(..))
|
|
import RPGEngine.Data.Default (defaultLevel, defaultPlayer)
|
|
|
|
import Graphics.Gloss ( play )
|
|
|
|
----------------------------------------------------------------------
|
|
|
|
-- This is the game loop.
|
|
-- It can receive input and update itself. It is rendered by a renderer.
|
|
playRPGEngine :: String -> Int -> IO()
|
|
playRPGEngine title fps = do
|
|
play window bgColor fps initGame render handleAllInput step
|
|
where window = initWindow title winDimensions winOffsets
|
|
step _ = checkPlaying -- TODO Do something with step? Check health etc.
|
|
|
|
-- TODO revert this
|
|
-- Initialize the game
|
|
initGame :: Game
|
|
initGame = Game { state = Menu }
|
|
-- initGame = Game{ state = initState }
|
|
-- where initState = Playing{
|
|
-- levels = [defaultLevel, otherLevel],
|
|
-- count = 0,
|
|
-- level = defaultLevel,
|
|
-- player = spawnPlayer defaultLevel defaultPlayer,
|
|
-- restart = initState
|
|
-- }
|
|
|
|
-- TODO remove this
|
|
otherLayout :: Layout
|
|
otherLayout = [
|
|
[Blocked, Blocked, Blocked],
|
|
[Blocked, Entrance, Blocked],
|
|
[Blocked, Walkable, Blocked],
|
|
[Blocked, Walkable, Blocked],
|
|
[Blocked, Walkable, Blocked],
|
|
[Blocked, Exit, Blocked],
|
|
[Blocked, Blocked, Blocked]
|
|
]
|
|
|
|
-- TODO remove this
|
|
otherLevel :: Level
|
|
otherLevel = Level {
|
|
layout = otherLayout,
|
|
index = [
|
|
(0, 0, Blocked),
|
|
(1, 0, Blocked),
|
|
(2, 0, Blocked),
|
|
(0, 1, Blocked),
|
|
(1, 1, Entrance),
|
|
(2, 1, Blocked),
|
|
(0, 2, Blocked),
|
|
(1, 2, Walkable),
|
|
(2, 2, Blocked),
|
|
(0, 3, Blocked),
|
|
(1, 3, Walkable),
|
|
(2, 3, Blocked),
|
|
(0, 4, Blocked),
|
|
(1, 4, Walkable),
|
|
(2, 4, Blocked),
|
|
(0, 5, Blocked),
|
|
(1, 5, Exit),
|
|
(2, 5, Blocked),
|
|
(0, 6, Blocked),
|
|
(1, 6, Blocked),
|
|
(2, 6, Blocked)
|
|
],
|
|
items = [],
|
|
entities = [
|
|
Entity{
|
|
entityId = "door",
|
|
entityX = 1,
|
|
entityY = 3,
|
|
entityName = "Epic door",
|
|
entityDescription = "epic description",
|
|
entityActions = [],
|
|
entityValue = Nothing,
|
|
entityHp = Nothing,
|
|
direction = North
|
|
}
|
|
]
|
|
} |