Roguelike
 All Classes Namespaces Functions Variables Typedefs Friends Pages
Functions
pblind_db Namespace Reference

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)
 

Detailed Description

Generates dungeons in a "procedurally-blind" manner.

The method for this dungeon generation technique is:

  1. Create a viable "first" dungeon room.
  2. Tunnel out from that room in a number of paths.
  3. At the end of the last path that was created, try to create another room.
  4. Repeat this until one of two conditions is met: a. The room limit is reached b. There is no viable room space at the end of the path.
  5. If the resulting dungeon does not have very many rooms, scrap it and start over. This currently happens <25% of the time.

Function Documentation

void pblind_db::build_dungeon ( int  width,
int  height,
int  target,
ChunkLayer cl 
)

The primary entry point for dungeon building.

Parameters
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.

Parameters
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).

Parameters
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.
Returns
the end of the path, or (-1,-1) if the path could not be built.
void pblind_db::build_start_room ( db::dungeon_meta dm)

Builds an initial room in the dungeon space.

Parameters
dm- instance of a dungeon to work on
See also
find_viable_starting_point
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;
Parameters
the_point- the point from which the function will start attempting to find a room space.
dm- instance of a dungeon to work on
Returns
a room representing the discovered room space, or ((-1,-1),(-1,-1)) if there is no such room.
IntPoint pblind_db::find_viable_starting_point ( const db::dungeon_meta dm)

Will find a starting point for the dungeon.

Parameters
dm- instance of a dungeon to work on
Returns
the point that was found.