lib/proceduralDunGen.h
/// Try and build a room at inert.
/// Uses random values generated in the function for size etc.
Try and build a room at inert.
Uses random values generated in the function for size etc.
Try and build a room at inert . Uses random values generated in the function for size etc .
int buildRoom(int **map, int rows, int cols, struct inertPoint inert)
{
    int height = (rand() % (MAXROOMSIZE - MINROOMSIZE)) + MINROOMSIZE;
    int width = (rand() % (MAXROOMSIZE - MINROOMSIZE)) + MINROOMSIZE;
    if(inert.dir == NORTH)
    {
        int offset = rand() % (width - 1); 
        if(testArea(map, rows, cols, inert.row - height + 1, inert.col - offset, height, width))
        {
            fillRectangle(map, inert.row - height + 1, inert.col - offset, height, width, FLOOR);
            return 1;
        }
    }
    if(inert.dir == SOUTH)
    {
        int offset = rand() % (width - 1); 
        if(testArea(map, rows, cols, inert.row, inert.col - offset, height, width))
        {
            fillRectangle(map, inert.row, inert.col - offset, height, width, FLOOR);
            return 1;
        }
    }
    if(inert.dir == WEST)
    {
        int offset = rand() % (height - 1); 
        if(testArea(map, rows, cols, inert.row - offset, inert.col - width + 1, height, width))
        {
            fillRectangle(map, inert.row - offset, inert.col - width + 1, height, width, FLOOR);
            return 1;
        }
    }
    if(inert.dir == EAST)
    {
        int offset = rand() % (height - 1); 
        if(testArea(map, rows, cols, inert.row - offset, inert.col, height, width))
        {
            fillRectangle(map, inert.row - offset, inert.col, height, width, FLOOR);
            return 1;
        }
    }
    return 0;
}
int buildRoom ( int * * map , int rows , int cols , struct inertPoint inert ) { int height = ( rand ( ) % ( MAXROOMSIZE - MINROOMSIZE ) ) + MINROOMSIZE ; int width = ( rand ( ) % ( MAXROOMSIZE - MINROOMSIZE ) ) + MINROOMSIZE ; if ( inert . dir == NORTH ) { int offset = rand ( ) % ( width - 1 ) ; if ( testArea ( map , rows , cols , inert . row - height + 1 , inert . col - offset , height , width ) ) { fillRectangle ( map , inert . row - height + 1 , inert . col - offset , height , width , FLOOR ) ; return 1 ; } } if ( inert . dir == SOUTH ) { int offset = rand ( ) % ( width - 1 ) ; if ( testArea ( map , rows , cols , inert . row , inert . col - offset , height , width ) ) { fillRectangle ( map , inert . row , inert . col - offset , height , width , FLOOR ) ; return 1 ; } } if ( inert . dir == WEST ) { int offset = rand ( ) % ( height - 1 ) ; if ( testArea ( map , rows , cols , inert . row - offset , inert . col - width + 1 , height , width ) ) { fillRectangle ( map , inert . row - offset , inert . col - width + 1 , height , width , FLOOR ) ; return 1 ; } } if ( inert . dir == EAST ) { int offset = rand ( ) % ( height - 1 ) ; if ( testArea ( map , rows , cols , inert . row - offset , inert . col , height , width ) ) { fillRectangle ( map , inert . row - offset , inert . col , height , width , FLOOR ) ; return 1 ; } } return 0 ; }
Try and build a room at inert.
Try and build a room at inert .
//printf("Testing a room at [%d][%d] towards %d\n", inert.row, inert.col,inert.dir); // To move the room a bit so the path isn't always in a corner // To move the room a bit so the path isn't always in a corner // To move the room a bit so the path isn't always in a corner // To move the room a bit so the path isn't always in a corner