build map encasing
This commit is contained in:
parent
c1717bc7d1
commit
ad52b9c037
1 changed files with 10 additions and 2 deletions
|
@ -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
|
||||||
|
@ -48,8 +53,11 @@ generateMap
|
||||||
-> Int -- ^ Map's width
|
-> Int -- ^ Map's width
|
||||||
-> 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
|
||||||
|
|
Loading…
Reference in a new issue