build map encasing

This commit is contained in:
nek0 2023-12-11 13:17:37 +01:00
parent c1717bc7d1
commit ad52b9c037

View file

@ -1,8 +1,13 @@
module Server.Map where module Server.Map where
import Control.Monad (foldM) import Control.Monad (foldM)
import qualified Data.Matrix as M import qualified Data.Matrix as M
import qualified Data.Vector as V
import Linear import Linear
import System.Random import System.Random
import Library.Types import Library.Types
@ -49,7 +54,10 @@ generateMap
-> IO ServerMap -- ^ resulting Map -> IO ServerMap -- ^ resulting Map
generateMap mapRows mapColumns = do generateMap mapRows mapColumns = do
let initMap = M.matrix mapRows mapColumns (const Air) let initMap = M.matrix mapRows mapColumns (const Air)
divide 0 0 mapRows mapColumns initMap wallRow = M.rowVector $ V.replicate (mapRows + 2) Wall
wallCol = M.colVector $ V.replicate mapColumns Wall
builtMap <- divide 0 0 mapRows mapColumns initMap
pure $ wallRow M.<-> (wallCol M.<|> builtMap M.<|> wallCol) M.<-> wallRow
where where
divide :: Int -> Int -> Int -> Int -> ServerMap -> IO ServerMap divide :: Int -> Int -> Int -> Int -> ServerMap -> IO ServerMap
divide rowOffset colOffset rowSize colSize tilemap divide rowOffset colOffset rowSize colSize tilemap