From c06edf3cc698f36e995719dc6e192c5663110f6d Mon Sep 17 00:00:00 2001 From: Griffin Smith Date: Fri, 13 Sep 2019 15:24:05 -0400 Subject: Place the chacracter in the level at startup time Randomly select a position in the largest contiguous region of the generated level in which to place the character at startup time. --- src/Xanthous/Generators.hs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/Xanthous/Generators.hs') diff --git a/src/Xanthous/Generators.hs b/src/Xanthous/Generators.hs index 740b39c5f082..6e2e89d14a14 100644 --- a/src/Xanthous/Generators.hs +++ b/src/Xanthous/Generators.hs @@ -33,13 +33,13 @@ generate -> Params gen -> Dimensions -> g - -> UArray (Word, Word) Bool + -> Cells generate SCaveAutomata = CaveAutomata.generate data GeneratorInput where GeneratorInput :: forall gen. SGenerator gen -> Params gen -> GeneratorInput -generateFromInput :: RandomGen g => GeneratorInput -> Dimensions -> g -> UArray (Word, Word) Bool +generateFromInput :: RandomGen g => GeneratorInput -> Dimensions -> g -> Cells generateFromInput (GeneratorInput sg ps) = generate sg ps parseGeneratorInput :: Opt.Parser GeneratorInput @@ -48,7 +48,7 @@ parseGeneratorInput = Opt.subparser $ (GeneratorInput <$> pure SCaveAutomata <*> CaveAutomata.parseParams) (Opt.progDesc "cellular-automata based cave generator")) -showCells :: UArray (Word, Word) Bool -> Text +showCells :: Cells -> Text showCells arr = let ((minX, minY), (maxX, maxY)) = bounds arr showCellVal True = "x" @@ -58,7 +58,7 @@ showCells arr = rows = row <$> [minY..maxY] in intercalate "\n" rows -cellsToWalls :: UArray (Word, Word) Bool -> EntityMap Wall +cellsToWalls :: Cells -> EntityMap Wall cellsToWalls cells = foldl' maybeInsertWall mempty . assocs $ cells where maybeInsertWall em (pos@(x, y), True) -- cgit 1.4.1