version 1.3 | | version 1.4 |
---|
| | |
static void roguelike_make_rooms(Room *Rooms,char **maze, int options); | | static void roguelike_make_rooms(Room *Rooms,char **maze, int options); |
static void roguelike_link_rooms(Room *Rooms,char **maze,int xsize,int ysize); | | static void roguelike_link_rooms(Room *Rooms,char **maze,int xsize,int ysize); |
| | |
| | |
| | int surround_check(char **layout,int i,int j,int Xsize, int Ysize){ |
| | /* 1 = wall to left, |
| | 2 = wall to right, |
| | 4 = wall above |
| | 8 = wall below */ |
| | int surround_index = 0; |
| | if((i > 0) && layout[i-1][j]!=0) surround_index |=1; |
| | if((i < Xsize-1) && layout[i+1][j]!=0) surround_index |=2; |
| | if((j > 0) && layout[i][j-1]!=0) surround_index |=4; |
| | if((j < Ysize-1) && layout[i][j+1]!=0) surround_index |=8; |
| | return surround_index; |
| | } |
| | |
| | |
/* actually make the layout: we work by a reduction process: | | /* actually make the layout: we work by a reduction process: |
first we make everything a well, then we remove areas to make rooms */ | | first we make everything a well, then we remove areas to make rooms */ |
| | |
| | |
maze[walk->x][walk->y] = '>'; | | maze[walk->x][walk->y] = '>'; |
| | |
/* convert all the '.' to 0, we're through witht he '.' */ | | /* convert all the '.' to 0, we're through witht he '.' */ |
| | /* also, fix any 'dangling doors' */ |
for(i=0;i<xsize;i++) | | for(i=0;i<xsize;i++) |
for(j=0;j<ysize;j++) | | for(j=0;j<ysize;j++) { |
if(maze[i][j]=='.') maze[i][j]=0; | | if(maze[i][j]=='.') maze[i][j]=0; |
| | if(maze[i][j]=='D') { /* remove bad door. */ |
| | int si = surround_check(maze,i,j,xsize,ysize); |
| | if(si!=3 && si!=12) maze[i][j]=0; |
| | } |
| | } |
| | |
return maze; | | return maze; |
} | | } |