From 12b788af5e3220a69fea7828a53c547e3605cb37 Mon Sep 17 00:00:00 2001 From: nek0 Date: Tue, 6 Oct 2020 04:19:07 +0200 Subject: [PATCH] more types --- src/Types/Application.hs | 8 +++++++- src/Types/GameMap.hs | 36 ++++++++++++++++++++++++++++++++++++ src/Types/Map.hs | 7 +++++-- 3 files changed, 48 insertions(+), 3 deletions(-) create mode 100644 src/Types/GameMap.hs diff --git a/src/Types/Application.hs b/src/Types/Application.hs index 342d819..1b29ab0 100644 --- a/src/Types/Application.hs +++ b/src/Types/Application.hs @@ -11,10 +11,11 @@ import qualified Data.Map.Strict as M -- internal imports import Types.Subsystems +import Types.LevelMap data GameData = GameData { gameState :: TVar State - -- , gameCurrentLevel :: Tvar Level + , gameStateData :: StateData , gameSubsystems :: Subsystems , gameActionTranslation :: TVar ActionTranslation , gameRunning :: TVar Bool @@ -61,3 +62,8 @@ data Level deriving (Enum, Eq, Show) type ActionTranslation = M.Map SDL.Keycode Action + +data GameStateData + = TestData + { testMap :: LevelMap + } diff --git a/src/Types/GameMap.hs b/src/Types/GameMap.hs new file mode 100644 index 0000000..f5cb04f --- /dev/null +++ b/src/Types/GameMap.hs @@ -0,0 +1,36 @@ +module Types.LevelMap where + +import Data.Vector + +import Linear + +data LevelMap = LevelMap + { mapLayers :: Vector MapLayer + , mapWalkLayer :: Word + , mapDimensions :: V2 Word + , mapTileMap :: TileMap + } + deriving (Eq, Show) + +newtype MapLayer = MapLayer + { layerTiles :: Vector Tile + } + deriving (Eq, Show) + +data Tile = Tile + { tileOffset :: V2 Float + , tileType :: TileType + } + deriving (Eq, Show) + +data TileType + = Wall + | Platform + | Decoration + deriving (Enum, Ord, Eq, Show) + +data TileMap = TileMap + { tileMapDimensions :: V2 Word + , tileMapPath :: FilePath + , tileMapIndex :: Word + } diff --git a/src/Types/Map.hs b/src/Types/Map.hs index 10b6e75..390c1e3 100644 --- a/src/Types/Map.hs +++ b/src/Types/Map.hs @@ -1,5 +1,7 @@ module Types.Map where +import qualified Data.Matrix as Mat + import Linear data Map = Map @@ -7,7 +9,8 @@ data Map = Map , mapStart :: (Word, V2 Word) -- | (Layer index, Position) } -data Layer = Layer - { +type Layer = Mat.Matrix Tile + +type Tile = V2 Float type LayerDescriptor = FilePath