on master help sign in
Rogue: document addRoom and mkLevel
commit6e2a7adb617ea720312e52f3be0782ccf15b5719 authorJonathan Daugherty <cygnus@foobox.com> dateFri 1 Aug 2014, 15:58 (12 years ago) parent30103d7
1 file changed+12−1
test/Rogue.hs+12−1
test/Rogue.hs+12−1
@@ -49,6 +49,8 @@ main = do
4949 (_finalWorld, ()) <- execRWST play vty world0
5050 shutdown vty
5151
52+-- |Generate a level randomly using the specified difficulty. Higher
53+-- difficulty means the level will have more rooms and cover a larger area.
5254mkLevel :: Int -> IO Level
5355mkLevel difficulty = do
5456 let size = 80 * difficulty
@@ -66,7 +68,16 @@ mkLevel difficulty = do
6668 geo <- foldM (addRoom levelWidth levelHeight) baseGeo (start : end : centers)
6769 return $ Level start end geo (buildGeoImage geo)
6870
69−addRoom :: Int -> Int -> Geo -> (Int, Int) -> IO Geo
71+-- |Add a room to a geography and return a new geography. Adds a
72+-- randomly-sized room centered at the specified coordinates.
73+addRoom :: Int
74+ -> Int
75+ -- ^The width and height of the geographical area
76+ -> Geo
77+ -- ^The geographical area to which a new room should be added
78+ -> Coord
79+ -- ^The desired center of the new room.
80+ -> IO Geo
7081addRoom levelWidth levelHeight geo (centerX, centerY) = do
7182 size <- randomRIO (5,15)
7283 let xMin = max 1 (centerX - size)