28 static void expand_wall(
char **newlayout,
int i,
int j,
char **
layout,
int xsize,
int ysize);
29 static void expand_door(
char **newlayout,
int i,
int j,
char **
layout,
int xsize,
int ysize);
46 int nxsize = xsize*2-1;
47 int nysize = ysize*2-1;
50 char **newlayout = (
char **)calloc(
sizeof(
char *), nxsize);
51 for (i = 0; i < nxsize; i++) {
52 newlayout[i] = (
char *)calloc(
sizeof(
char), nysize);
55 for (i = 0; i < xsize; i++) {
56 for (j = 0; j < ysize; j++) {
57 switch (layout[i][j]) {
73 for (i = 0; i < xsize; i++) {
96 newlayout[i*2][j*2] = layout[i][j];
125 if (i+1 < xsize && layout[i+1][j] == ch) {
130 if (layout[i][j+1] == ch) {
133 if (i+1 < xsize && layout[i+1][j+1] == ch) {
158 int wall_pattern =
calc_pattern(
'#', layout, i, j, xsize, ysize);
159 int door_pattern =
calc_pattern(
'D', layout, i, j, xsize, ysize);
160 int both_pattern = wall_pattern|door_pattern;
162 newlayout[i*2][j*2] =
'#';
164 if (both_pattern&1) {
166 newlayout[i*2+1][j*2] = layout[i+1][j];
171 if (both_pattern&2) {
173 newlayout[i*2][j*2+1] = layout[i][j+1];
176 if (wall_pattern == 7) {
179 newlayout[i*2+1][j*2+1] =
'#';
201 int wall_pattern =
calc_pattern(
'#', layout, i, j, xsize, ysize);
202 int door_pattern =
calc_pattern(
'D', layout, i, j, xsize, ysize);
208 if (wall_pattern&3) {
209 join_pattern = wall_pattern;
211 join_pattern = door_pattern;
214 newlayout[i*2][j*2] =
'D';
216 if (join_pattern&1) {
218 newlayout[i*2+1][j*2] =
'D';
223 if (join_pattern&2) {
225 newlayout[i*2][j*2+1] =
'D';
static void expand_wall(char **newlayout, int i, int j, char **layout, int xsize, int ysize)
Expand a wall.
static void expand_door(char **newlayout, int i, int j, char **layout, int xsize, int ysize)
Expand a door.
static int calc_pattern(char ch, char **layout, int i, int j, int xsize, int ysize)
Returns a bitmap that represents which squares on the right and bottom edges of a square (i...
static void expand_misc(char **newlayout, int i, int j, char **layout)
Copy the old tile X into the new one at location (i*2, j*2) and fill up the rest of the 2x2 result wi...
Expands a layout by 2x in each dimension.
char ** expand2x(char **layout, int xsize, int ysize)
Expands the layout be a factor 2.