lib/proceduralDunGen.h
/// Find a spot to start an offshoot of an existing room, to place a path and room there.
///
/// 1. Randomly searches for a suitable wall that sits next to a room.
/// 2. When found, it tests to see if a path (random length) could be made there
/// 3. If this is the case, try and build a room there
/// 4. If the room could be made, retroactively attach the path to it.
Find a spot to start an offshoot of an existing room, to place a path and room there.
1. Randomly searches for a suitable wall that sits next to a room.
2. When found, it tests to see if a path (random length) could be made there
3. If this is the case, try and build a room there
4. If the room could be made, retroactively attach the path to it.
Find a spot to start an offshoot of an existing room to place a path and room there . 1 . Randomly searches for a suitable wall that sits next to a room . 2 . When found it tests to see if a path ( random length ) could be made there 3 . If this is the case try and build a room there 4 . If the room could be made retroactively attach the path to it .
void buildFeature(int **map, int rows, int cols)
{
    struct inertPoint c;
    int pathLength;
    struct inertPoint startOfRoom;
    do {
        do {
            c = pickWall(map, rows,cols);
            pathLength = (rand() % (MAXPATHLENGTH - MINPATHLENGTH)) + MINPATHLENGTH;
        } while(!testPath(map, rows, cols, c, pathLength)); 
        startOfRoom = follow(c, pathLength);
    } while(!buildRoom(map, rows, cols, startOfRoom)); 
    buildPath(map, c, pathLength);
}
void buildFeature ( int * * map , int rows , int cols ) { struct inertPoint c ; int pathLength ; struct inertPoint startOfRoom ; do { do { c = pickWall ( map , rows , cols ) ; pathLength = ( rand ( ) % ( MAXPATHLENGTH - MINPATHLENGTH ) ) + MINPATHLENGTH ; } while ( ! testPath ( map , rows , cols , c , pathLength ) ) ; startOfRoom = follow ( c , pathLength ) ; } while ( ! buildRoom ( map , rows , cols , startOfRoom ) ) ; buildPath ( map , c , pathLength ) ; }
Find a spot to start an offshoot of an existing room, to place a path and room there.
Find a spot to start an offshoot of an existing room to place a path and room there .
// Keep testing random paths until a suitable is found. // Keep trying out room configurations until a suitable is found.