Guest User

Untitled

a guest
Jan 22nd, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.58 KB | None | 0 0
  1. Create world(first time)
  2. {
  3. -Create an array to hold tiles
  4.  
  5. -Fill all locations with wall tiles
  6.  
  7. -Pick location near center of world
  8.  
  9. -Define the room's dimensions
  10.  
  11. -Identify the top-left corner, relative to door position
  12.  
  13. -Hollow out room
  14. }
  15.  
  16. Pick random empty space for start(not first time)
  17. {
  18. -generate random location
  19. -check if empty, if not, back a step
  20. }
  21.  
  22.  
  23. Pick a random direction
  24. {
  25. -generate random number (1-4 for the 4 directions)
  26. -set up direction modifier based on random number
  27. }
  28.  
  29. Locate wall for a door
  30. {
  31. -Find the start and end of a wall
  32. -Store for current wall
  33. }
  34.  
  35. Pick a wall location
  36. {
  37. -Find a random location between start and end of wall
  38. -Store door position
  39. }
  40.  
  41. Check if door (not first time)
  42. {
  43. -Back to "pick a wall location" if door found.
  44. -If this happens twice, pick an unchecked direction using
  45.  
  46. "pick a random direction"
  47. -If this happens in all directions, "pick random empty space
  48.  
  49. for start"
  50. }
  51.  
  52. Create a room
  53. {
  54.  
  55. Define dimensions for new room
  56. {
  57. -pick random length and height
  58. -check area
  59. }
  60.  
  61. Check space for room length. (not first time)
  62. {
  63. -Check for adjacency to room or edge
  64. -If adjacent to room "Insert a door between adjacent rooms"
  65. -If room meets edge or enters another room "Adjust size to
  66.  
  67. fit"
  68. -If room length is ok, store a value to express this.
  69. }
  70.  
  71. Check space left and right of door for max width(not first
  72.  
  73. time)
  74. {
  75. -Far left may be placed anywhere that satisfies these
  76.  
  77. requirements:
  78. ->Maximum position for far left is in line with door
  79. ->Minimum position for far right is in line with door
  80. -Check for adjacency to room or edge, using far left and far
  81.  
  82. right
  83. -If room meets edge or enters another room "Adjust size to
  84.  
  85. fit"
  86. -If room width is ok, store a value to express this.
  87. }
  88.  
  89. Adjust size to fit
  90. {
  91. -Reduce wall length/size until it is adjacent to next room or
  92.  
  93. inside map
  94. -50% chance to add door using "Insert a door between adjacent
  95.  
  96. rooms"
  97. -"Check Sizes"
  98. -store new width and length (whatever is relevant)
  99. }
  100.  
  101. Check sizes
  102. {
  103. -If wall smaller than minimum width/length, add to a fail
  104.  
  105. counter and "Repeat process"
  106. -If area is smaller than minimum area, add to fail counter and
  107.  
  108. "Repeat process"
  109. }
  110.  
  111. Create door(If the sizes all check out)
  112. {
  113. -If the sizes all check out
  114. -change tile at door location to a door tile
  115. }
  116.  
  117. Repeat process
  118. {
  119. -Check if at room limit
  120. -Check if at fail limit
  121. -If ok, then back to "Pick random empty space for start"
  122. }
  123. }
  124.  
  125. Insert a door between adjacent rooms (If room was adjusted and
  126.  
  127. is adjacent)
  128. {
  129. -"Locate wall for a door"
  130. -Add a door
  131. }
Add Comment
Please, Sign In to add comment