add tables

This commit is contained in:
nek0 2018-03-31 23:22:10 +02:00
parent d1e130b5a9
commit d57e502c74
10 changed files with 36 additions and 4 deletions

BIN
assets/misc/table1.kra Normal file

Binary file not shown.

BIN
assets/misc/table1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 671 B

BIN
assets/misc/table2.kra Normal file

Binary file not shown.

BIN
assets/misc/table2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 553 B

BIN
assets/misc/tableCorner.kra Normal file

Binary file not shown.

BIN
assets/misc/tableCorner.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 600 B

View file

@ -56,15 +56,19 @@ load = do
mwalltnw <- createImage nvg (FileName "assets/walls/wall_t_nw.png") 0 mwalltnw <- createImage nvg (FileName "assets/walls/wall_t_nw.png") 0
mwallcross <- createImage nvg (FileName "assets/walls/wall_cross.png") 0 mwallcross <- createImage nvg (FileName "assets/walls/wall_cross.png") 0
mmiscbox1 <- createImage nvg (FileName "assets/misc/box1.png") 0 mmiscbox1 <- createImage nvg (FileName "assets/misc/box1.png") 0
mmisctable1 <- createImage nvg (FileName "assets/misc/table1.png") 0
mmisctable2 <- createImage nvg (FileName "assets/misc/table2.png") 0
mmisctableC <- createImage nvg (FileName "assets/misc/tableCorner.png") 0
_ <- createFont nvg "bedstead" _ <- createFont nvg "bedstead"
(FileName "assets/font/Bedstead-Semicondensed.ttf") (FileName "assets/font/Bedstead-Semicondensed.ttf")
let mimgs = [ mwallasc, mwalldesc, let mimgs = [ mwallasc, mwalldesc,
mwallcornern, mwallcornere, mwallcorners, mwallcornerw, mwallcornern, mwallcornere, mwallcorners, mwallcornerw,
mwalltne, mwalltse, mwalltsw, mwalltnw, mwallcross, mwalltne, mwalltse, mwalltsw, mwalltnw, mwallcross,
mmiscbox1 mmiscbox1,
mmisctable1, mmisctable2, mmisctableC
] ]
when (any isNothing mimgs) $ do when (any isNothing mimgs) $ do
logIO Error "Failed to load walls" logIO Error "Failed to load image assets"
exitFailure exitFailure
let imgs = zipWith (\a b -> (a, fromJust b)) [ImgWallAsc ..] mimgs let imgs = zipWith (\a b -> (a, fromJust b)) [ImgWallAsc ..] mimgs
return UserData return UserData

View file

@ -51,7 +51,10 @@ loadMap = do
{ worldState = nws { worldState = nws
, stateData = MenuData , stateData = MenuData
{ mapMat = mat { mapMat = mat
, imgMat = inter , imgMat = M.fromList (nrows inter) (ncols inter) $
Prelude.map
(\a -> if a == Just ImgEmpty then Nothing else a)
(M.toList inter)
, initCoords = (0, 500) , initCoords = (0, 500)
} }
, uuid = [uu] , uuid = [uu]

View file

@ -9,6 +9,7 @@ import Types.UserData
data Cluster data Cluster
= ClusterBox1 = ClusterBox1
| ClusterCornerTable
deriving (Enum, Bounded) deriving (Enum, Bounded)
clusterMat :: Cluster -> Matrix (Maybe ImgId) clusterMat :: Cluster -> Matrix (Maybe ImgId)
@ -18,9 +19,16 @@ clusterMat ClusterBox1 =
[ [Just ImgMiscBox1] [ [Just ImgMiscBox1]
-- , [Nothing, Nothing, Nothing] -- , [Nothing, Nothing, Nothing]
] ]
clusterMat ClusterCornerTable =
M.fromLists
[ [Just ImgEmpty, Just ImgMiscTable2, Just ImgMiscTableCorner]
, [Just ImgEmpty, Just ImgEmpty , Just ImgMiscTable1]
, [Just ImgEmpty, Just ImgEmpty , Just ImgEmpty]
]
clusterRoom :: Cluster -> TileState clusterRoom :: Cluster -> TileState
clusterRoom ClusterBox1 = Offi clusterRoom ClusterBox1 = Offi
clusterRoom ClusterCornerTable = Offi
instance Size Cluster where instance Size Cluster where
size c = size c =

View file

@ -40,7 +40,8 @@ data StateData
} }
data ImgId data ImgId
= ImgWallAsc = ImgEmpty -- TODO: Find better solution thatn empty image.
| ImgWallAsc
| ImgWallDesc | ImgWallDesc
| ImgWallCornerN | ImgWallCornerN
| ImgWallCornerE | ImgWallCornerE
@ -52,10 +53,16 @@ data ImgId
| ImgWallTNW | ImgWallTNW
| ImgWallCross | ImgWallCross
| ImgMiscBox1 | ImgMiscBox1
| ImgMiscTable1
| ImgMiscTable2
| ImgMiscTableCorner
deriving (Show, Eq, Ord, Enum) deriving (Show, Eq, Ord, Enum)
isWall :: ImgId -> Bool isWall :: ImgId -> Bool
isWall ImgMiscBox1 = False isWall ImgMiscBox1 = False
isWall ImgMiscTable1 = False
isWall ImgMiscTable2 = False
isWall ImgMiscTableCorner = False
isWall _ = True isWall _ = True
imgObstacle :: Maybe ImgId -> [(Boundaries Double)] imgObstacle :: Maybe ImgId -> [(Boundaries Double)]
@ -98,6 +105,16 @@ imgObstacle (Just ImgWallCross) =
[ Boundaries (0.34, 0) (0.66, 1) [ Boundaries (0.34, 0) (0.66, 1)
, Boundaries (0, 0.34) (1, 0.66) , Boundaries (0, 0.34) (1, 0.66)
] ]
imgObstacle (Just ImgMiscTable1) =
[ Boundaries (0, 0.34) (1, 1)
]
imgObstacle (Just ImgMiscTable2) =
[ Boundaries (0, 0) (0.63, 1)
]
imgObstacle (Just ImgMiscTableCorner) =
[ Boundaries (0, 0) (0.63, 1)
, Boundaries (0, 0.34) (1, 1)
]
imgObstacle _ = [] imgObstacle _ = []
data FontId data FontId