Convert generated levels to walls

Add support for converting generated levels to walls, and merge one into
the entity map at the beginning of the game.

There's nothing here that guarantees the character ends up *inside* the
level though (they almost always don't) so that'll have to be slotted
into the level generation process.
This commit is contained in:
Griffin Smith 2019-09-09 20:54:33 -04:00
parent e01cf9b056
commit 9ebdc6fbb4
20 changed files with 355 additions and 114 deletions

View file

@ -41,7 +41,7 @@ test = testGroup "Xanthous.Generators.Util"
$ randInitialize dims aliveChance
in bounds res === ((0, 0), (dims ^. width, dims ^. height))
]
, testGroup "numAliveNeighbors"
, testGroup "numAliveNeighborsM"
[ testProperty "maxes out at 8" $ \(GenArray (arr :: Array (Word, Word) Bool)) loc ->
let
act :: forall s. ST s Word
@ -51,6 +51,17 @@ test = testGroup "Xanthous.Generators.Util"
res = runST act
in counterexample (show res) $ between 0 8 res
]
, testGroup "numAliveNeighbors"
[ testProperty "is equivalient to runST . numAliveNeighborsM . thaw" $
\(GenArray (arr :: Array (Word, Word) Bool)) loc ->
let
act :: forall s. ST s Word
act = do
mArr <- thaw @_ @_ @_ @(STUArray s) arr
numAliveNeighborsM mArr loc
res = runST act
in numAliveNeighbors arr loc === res
]
, testGroup "cloneMArray"
[ testCase "clones the array" $ runST $
let