Functions | |
void | build_start_room (db::dungeon_meta &dm) |
Room | find_viable_room_space (IntPoint the_point, db::dungeon_meta &dm) |
IntPoint | find_viable_starting_point (const db::dungeon_meta &dm) |
IntPoint | build_path (IntPoint start, int direction, db::dungeon_meta &dm) |
void | build_dungeon (int width, int height, int target, ChunkLayer &cl) |
void | build_dungeon_recursive (int target, db::dungeon_meta &dm) |
Generates dungeons in a "procedurally-blind" manner.
The method for this dungeon generation technique is:
void pblind_db::build_dungeon | ( | int | width, |
int | height, | ||
int | target, | ||
ChunkLayer & | cl | ||
) |
The primary entry point for dungeon building.
target | - The target number of rooms to build. |
cl | - Instance of a ChunkLayer to use. |
void pblind_db::build_dungeon_recursive | ( | int | target, |
db::dungeon_meta & | dm | ||
) |
A recursive helper function to build the dungeon.
Finds a viable wall block in the given room, building paths outward from those wall blocks and often building rooms at the ends of those paths. Every time a new room is built, the function is called again.
target | - The target number of rooms. |
dm | - instance of a dungeon to work on |
IntPoint pblind_db::build_path | ( | IntPoint | start, |
int | direction, | ||
db::dungeon_meta & | dm | ||
) |
Builds a path starting at the given point.
Will attempt to build a path starting from the given point, and return the point where the path ends; if the path cannot be built, returns IntPoint(-1, -1).
start | - the starting point for this path. |
direction | - The starting direction of the path, where 0 = up, |
dm | - instance of a dungeon to work on 1 = right, 2 = down, and 3 = left. |
void pblind_db::build_start_room | ( | db::dungeon_meta & | dm | ) |
Builds an initial room in the dungeon space.
dm | - instance of a dungeon to work on |
Room pblind_db::find_viable_room_space | ( | IntPoint | the_point, |
db::dungeon_meta & | dm | ||
) |
Will find and return a viable room space, and if there is no such space, will return a room with coordinates (-1,-1),(-1,-1).
Pseudocode for this function:
Declare min room width and min room height; declare and define test_room based on this width and height; declare upper_bound, lower_bound, left_bound, right_bound = 1
if test_room collides with something solid: return something nullish
while (room width < max) and (room height < max) AND (upper_bound + lower_bound + left_bound + right_bound > 0):
move all of test_room's points out; (subroutine probably) subtract upper_bound from row value of both upper points; subtract left_bound from col value of both left side points; add lower_bound to row value of both lower points; add right_bound to col value of both right side points; "scan" across those newly created edges; if, during the scan, we ran into a solid block: which side did it occur on? Set the *_bound to 0 for that side; move the points on that side one step toward the room center;
the_point | - the point from which the function will start attempting to find a room space. |
dm | - instance of a dungeon to work on |
IntPoint pblind_db::find_viable_starting_point | ( | const db::dungeon_meta & | dm | ) |
Will find a starting point for the dungeon.
dm | - instance of a dungeon to work on |