lib/proceduralDunGen.h
/// See if the block and surrounding blocks are available.
//
// Used to make sure a room can be placed.
// Has a lot of checks to make sure it doesn't go out of bounds of the array.
See if the block and surrounding blocks are available.
Used to make sure a room can be placed.
Has a lot of checks to make sure it doesn't go out of bounds of the array.
See if the block and surrounding blocks are available . Used to make sure a room can be placed . Has a lot of checks to make sure it doesn ' t go out of bounds of the array .
int testSurrounding(int **map, int rows, int cols, int row, int col)
{
    if(row < 1 || col < 1 || row > (rows - 2) || col > (cols - 2) || map[row][col] != WALL) return 0; 
    if 
        (
         map[row-1][col] != WALL ||
         map[row+1][col] != WALL ||
         map[row][col-1] != WALL ||
         map[row][col+1] != WALL ||
         map[row-1][col-1] != WALL ||
         map[row-1][col+1] != WALL ||
         map[row+1][col-1] != WALL ||
         map[row+1][col+1] != WALL
        ) return 0;
    return 1; 
}
int testSurrounding ( int * * map , int rows , int cols , int row , int col ) { if ( row < 1 || col < 1 || row > ( rows - 2 ) || col > ( cols - 2 ) || map [ row ] [ col ] != WALL ) return 0 ; if ( map [ row - 1 ] [ col ] != WALL || map [ row + 1 ] [ col ] != WALL || map [ row ] [ col - 1 ] != WALL || map [ row ] [ col + 1 ] != WALL || map [ row - 1 ] [ col - 1 ] != WALL || map [ row - 1 ] [ col + 1 ] != WALL || map [ row + 1 ] [ col - 1 ] != WALL || map [ row + 1 ] [ col + 1 ] != WALL ) return 0 ; return 1 ; }
See if the block and surrounding blocks are available.
See if the block and surrounding blocks are available .
// Test that the block itself is a wall and thus available // Test that blocks surrounding [row][col] are available // Block and all surrounding blocks are wall and thus safe to build on.