… | |
… | |
12 | |
12 | |
13 | #include <global.h> |
13 | #include <global.h> |
14 | #include "random_map.h" |
14 | #include "random_map.h" |
15 | #include "rproto.h" |
15 | #include "rproto.h" |
16 | |
16 | |
17 | Maze |
17 | void |
18 | make_snake_layout (int xsize, int ysize, int options) |
18 | make_snake_layout (Maze maze, int options) |
19 | { |
19 | { |
20 | int i, j; |
20 | int i, j; |
21 | |
21 | |
22 | Maze maze (xsize, ysize); |
22 | maze->clear (); |
|
|
23 | maze->border (); |
23 | |
24 | |
24 | /* write the outer walls */ |
25 | int xsize = maze->w; |
25 | for (i = 0; i < xsize; i++) maze[i][0] = maze[i][ysize - 1] = '#'; |
26 | int ysize = maze->h; |
26 | for (j = 0; j < ysize; j++) maze[0][j] = maze[xsize - 1][j] = '#'; |
|
|
27 | |
27 | |
28 | /* Bail out if the size is too small to make a snake. */ |
28 | /* Bail out if the size is too small to make a snake. */ |
29 | if (xsize < 8 || ysize < 8) |
29 | if (xsize < 8 || ysize < 8) |
30 | return maze; |
30 | return; |
31 | |
31 | |
32 | /* decide snake orientation--vertical or horizontal , and |
32 | /* decide snake orientation--vertical or horizontal , and |
33 | make the walls and place the doors. */ |
33 | make the walls and place the doors. */ |
34 | |
34 | |
35 | if (rndm (2)) |
35 | if (rndm (2)) |
… | |
… | |
94 | else |
94 | else |
95 | { |
95 | { |
96 | maze[1][1] = '>'; |
96 | maze[1][1] = '>'; |
97 | maze[xsize - 2][ysize - 2] = '<'; |
97 | maze[xsize - 2][ysize - 2] = '<'; |
98 | } |
98 | } |
99 | |
|
|
100 | return maze; |
|
|
101 | } |
99 | } |
102 | |
100 | |