Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Create world(first time)
- {
- -Create an array to hold tiles
- -Fill all locations with wall tiles
- -Pick location near center of world
- -Define the room's dimensions
- -Identify the top-left corner, relative to door position
- -Hollow out room
- }
- Pick random empty space for start(not first time)
- {
- -generate random location
- -check if empty, if not, back a step
- }
- Pick a random direction
- {
- -generate random number (1-4 for the 4 directions)
- -set up direction modifier based on random number
- }
- Locate wall for a door
- {
- -Find the start and end of a wall
- -Store for current wall
- }
- Pick a wall location
- {
- -Find a random location between start and end of wall
- -Store door position
- }
- Check if door (not first time)
- {
- -Back to "pick a wall location" if door found.
- -If this happens twice, pick an unchecked direction using
- "pick a random direction"
- -If this happens in all directions, "pick random empty space
- for start"
- }
- Create a room
- {
- Define dimensions for new room
- {
- -pick random length and height
- -check area
- }
- Check space for room length. (not first time)
- {
- -Check for adjacency to room or edge
- -If adjacent to room "Insert a door between adjacent rooms"
- -If room meets edge or enters another room "Adjust size to
- fit"
- -If room length is ok, store a value to express this.
- }
- Check space left and right of door for max width(not first
- time)
- {
- -Far left may be placed anywhere that satisfies these
- requirements:
- ->Maximum position for far left is in line with door
- ->Minimum position for far right is in line with door
- -Check for adjacency to room or edge, using far left and far
- right
- -If room meets edge or enters another room "Adjust size to
- fit"
- -If room width is ok, store a value to express this.
- }
- Adjust size to fit
- {
- -Reduce wall length/size until it is adjacent to next room or
- inside map
- -50% chance to add door using "Insert a door between adjacent
- rooms"
- -"Check Sizes"
- -store new width and length (whatever is relevant)
- }
- Check sizes
- {
- -If wall smaller than minimum width/length, add to a fail
- counter and "Repeat process"
- -If area is smaller than minimum area, add to fail counter and
- "Repeat process"
- }
- Create door(If the sizes all check out)
- {
- -If the sizes all check out
- -change tile at door location to a door tile
- }
- Repeat process
- {
- -Check if at room limit
- -Check if at fail limit
- -If ok, then back to "Pick random empty space for start"
- }
- }
- Insert a door between adjacent rooms (If room was adjusted and
- is adjacent)
- {
- -"Locate wall for a door"
- -Add a door
- }
Add Comment
Please, Sign In to add comment