Make more sounds positional

This commit is contained in:
2021-04-23 17:27:32 +02:00
parent ffe4a8083b
commit 4c611ba4aa
4 changed files with 75 additions and 63 deletions
+8 -6
View File
@@ -17,7 +17,7 @@ import Data.Tree
import Control.Monad.State
import System.Random
data Annotation
data Annotation g
= Lock Int
| Key Int
| Corridor
@@ -28,18 +28,19 @@ data Annotation
| FirstWeapon
| StartRoom
| EndRoom
| OrAno [[Annotation]]
| OrAno [[Annotation g]]
| SpecificRoom (State g (Tree (Either Room Room)))
addLock :: RandomGen g => Int -> Tree [Annotation] -> State g (Tree [Annotation])
addLock :: RandomGen g => Int -> Tree [Annotation g] -> State g (Tree [Annotation g])
addLock i t = do
(beforeLock, afterLock) <- splitTrunk t
newBefore <- applyToRandomNode (Key i :) beforeLock
return $ addToTrunk newBefore [Node [Lock i] afterLock]
padCorridors :: Tree [Annotation] -> Tree [Annotation]
padCorridors :: Tree [Annotation g] -> Tree [Annotation g]
padCorridors (Node x xs) = Node [Corridor] [Node x (map padCorridors xs)]
randomPadCorridors :: RandomGen g => Tree [Annotation] -> State g (Tree [Annotation])
randomPadCorridors :: RandomGen g => Tree [Annotation g] -> State g (Tree [Annotation g])
randomPadCorridors (Node x xs) = do
n <- state $ randomR (1, 3)
xs' <- mapM randomPadCorridors xs
@@ -49,7 +50,7 @@ roomThenCorridor :: RandomGen g => Room -> State g (Tree (Either Room Room))
roomThenCorridor theRoom = fmap (\r -> Node (Left theRoom) [(pure . Right) r])
(randomiseOutLinks corridor)
annoToRoomTree :: RandomGen g => [Annotation] -> State g (Tree (Either Room Room))
annoToRoomTree :: RandomGen g => [Annotation g] -> State g (Tree (Either Room Room))
annoToRoomTree [OrAno as] = do
a <- takeOne as
annoToRoomTree a
@@ -66,6 +67,7 @@ annoToRoomTree [StartRoom] = do
w <- state $ randomR (100,400)
h <- state $ randomR (200,400)
fmap (pure . Right) $ randomiseOutLinks (shiftRoomBy ((-20,-20),0) $ roomRectAutoLinks w h)
annoToRoomTree (SpecificRoom rt:_) = rt
annoToRoomTree _ = do
w <- state $ randomR (100,400)
h <- state $ randomR (200,400)