From ad52b9c0379f1f7aac2cfb62fea7c6167a95931b Mon Sep 17 00:00:00 2001 From: nek0 Date: Mon, 11 Dec 2023 13:17:37 +0100 Subject: [PATCH] build map encasing --- src-server/Server/Map.hs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src-server/Server/Map.hs b/src-server/Server/Map.hs index 27f68df..ef6db61 100644 --- a/src-server/Server/Map.hs +++ b/src-server/Server/Map.hs @@ -1,8 +1,13 @@ module Server.Map where import Control.Monad (foldM) + import qualified Data.Matrix as M + +import qualified Data.Vector as V + import Linear + import System.Random import Library.Types @@ -48,8 +53,11 @@ generateMap -> Int -- ^ Map's width -> IO ServerMap -- ^ resulting Map generateMap mapRows mapColumns = do - let initMap = M.matrix mapRows mapColumns (const Air) - divide 0 0 mapRows mapColumns initMap + let initMap = M.matrix mapRows mapColumns (const Air) + 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 divide :: Int -> Int -> Int -> Int -> ServerMap -> IO ServerMap divide rowOffset colOffset rowSize colSize tilemap