Ready for takeoff

This commit is contained in:
Tibo De Peuter 2022-12-13 23:21:51 +01:00
parent b36a7a4b95
commit b622b93932
10 changed files with 106 additions and 29 deletions

39
lib/RPGEngine.hs Normal file
View file

@ -0,0 +1,39 @@
-- Allows to play a game using RPGEngine.
-- Includes all logic and rendering.
module RPGEngine
( playRPGEngine
) where
import Game
import RenderGame
import Graphics.Gloss (
Color(..)
, black
, play
)
----------------------------- Constants ------------------------------
-- Dimensions for main window
winDimensions :: (Int, Int)
winDimensions = (1280, 720)
-- Offsets for main window
winOffsets :: (Int, Int)
winOffsets = (0, 0)
-- Game background color
bgColor :: Color
bgColor = black
----------------------------------------------------------------------
-- This is the gameloop.
-- 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 handleInputs step
where window = initWindow title winDimensions winOffsets
step _ g = g -- TODO Do something with step?
handleInputs _ g = g -- TODO Implement inputHanlders

View file

@ -1,10 +0,0 @@
module VoorbeeldModule
( hoi -- oplijsting van de publieke functies - als je deze lijst en de haakjes weglaat, wordt alles publiek
, hallo
) where
hoi :: String
hoi = "Hoi"
hallo :: String
hallo = "Hallo"

22
lib/data/Game.hs Normal file
View file

@ -0,0 +1,22 @@
-- Representation of all the game's data
module Game
( Game(..)
, initGame -- Initialize the game
) where
----------------------------- Constants ------------------------------
data Game = Game {
-- TODO Add more
playerName :: String
}
----------------------------------------------------------------------
-- Initialize the game
-- TODO Expand
initGame :: Game
initGame = Game {
playerName = "Tibo"
}

19
lib/render/RenderGame.hs Normal file
View file

@ -0,0 +1,19 @@
-- Allows to render the played game
module RenderGame
( initWindow -- Initialize a window to play in
, render -- Rener the game
) where
import Game
import Graphics.Gloss
----------------------------------------------------------------------
-- Render the game
render :: Game -> Picture
render _ = Blank
-- Initialize a window to play in
initWindow :: String -> (Int, Int) -> (Int, Int) -> Display
initWindow title dims offs = InWindow title dims offs