fix map generation bug
This commit is contained in:
parent
61e19d3378
commit
d92763fe09
1 changed files with 7 additions and 7 deletions
|
@ -21,7 +21,7 @@ generateMap
|
|||
-> Int -- ^ Map's height
|
||||
-> IO Map -- ^ resulting Map
|
||||
generateMap mapWidth mapHeight = do
|
||||
let initMap = M.matrix mapWidth mapHeight (const Air)
|
||||
let initMap = M.matrix mapHeight mapWidth (const Air)
|
||||
divide 0 0 mapHeight mapWidth initMap
|
||||
where
|
||||
divide :: Int -> Int -> Int -> Int -> Map -> IO Map
|
||||
|
@ -39,7 +39,7 @@ generateMap mapWidth mapHeight = do
|
|||
colHole2 <- randomRIO (crossCol + 1, colSize - 1)
|
||||
|
||||
-- determine all possible passages
|
||||
let holes =
|
||||
let allHoles =
|
||||
[ (rowHole1, crossCol)
|
||||
, (rowHole2, crossCol)
|
||||
, (crossRow, colHole1)
|
||||
|
@ -47,14 +47,14 @@ generateMap mapWidth mapHeight = do
|
|||
]
|
||||
|
||||
-- drop one of the passages randomly
|
||||
-- randomDropIndex <- randomRIO (0, length allHoles - 1)
|
||||
let -- randomDrop = allHoles !! randomDropIndex
|
||||
-- holes = filter (/= randomDrop) allHoles
|
||||
randomDropIndex <- randomRIO (0, length allHoles - 1)
|
||||
let randomDrop = allHoles !! randomDropIndex
|
||||
holes = filter (/= randomDrop) allHoles
|
||||
|
||||
crossedMap = M.mapPos
|
||||
(\(r, c) tile ->
|
||||
if (r - rowOffset == crossRow || c - colOffset == crossCol) &&
|
||||
(r - rowOffset <= rowSize || c - colOffset <= colSize)
|
||||
if (r - rowOffset == crossRow && c - colOffset > 0 && c - colOffset <= colSize) ||
|
||||
(c - colOffset == crossCol && r - rowOffset > 0 && r - rowOffset <= rowSize)
|
||||
then if (r - rowOffset, c - colOffset) `elem` holes
|
||||
then Air
|
||||
else Wall
|
||||
|
|
Loading…
Reference in a new issue