11 while(Bgetc(b) != '\n')
15 /* parse a level file */
19 int x = 0, y = 0, depth = 0;
23 b = Bopen(layout, OREAD);
25 fprint(2, "could not open file %s: %r\n", layout);
31 while((c = Bgetc(b)) > 0) {
40 orig.board[depth][x][y].which = 0;
48 orig.board[depth][x++][y].which = c-48;
66 t = (type/36)*Facey * 9 + ((type%36)/4)*Facex;
70 t = 3*Facey + (((type+12)%36)/4)*Facex;
74 t = 4*Facey + (((type+28)%36)/4)*Facex;
86 * the first 108 bricks are 4 of each, 36 per line:
89 * then multiply by the size of a single tile.
90 * the next 4 are the seasons, so x = index%4...
95 p = Pt(((type%36)/4)*Facex, (type/36)*Facey);
97 p = Pt((type%4)*Facex, 3*Facey);
99 p = Pt((((type+12)%36)/4)*Facex, 3*Facey);
101 p = Pt(((type+4)%4)*Facex, 4*Facey);
103 p = Pt((((type+28)%36)/4)*Facex, 4*Facey);
107 /* use the seed to generate a replayable game */
117 for (x = 0; x < Tiles; x++)
120 for(x = 0; x < Tiles; x++) {
128 for(d = 0; d < Depth; d++)
129 for(y = 0; y < Ly; y++)
130 for(x = 0; x < Lx; x++)
131 if(orig.board[d][x][y].which == 1) {
133 orig.board[d][x][y].type = indextype(order[n]);
134 p = indexpt(order[n++]);
135 orig.board[d][x][y].start = p;
136 orig.board[d][x+1][y].start = p;
137 orig.board[d][x][y+1].start = p;
138 orig.board[d][x+1][y+1].start = p;
141 if(n != orig.remaining)
142 fprint(2, "level improperly generated: %d elements, "
143 "should have %d\n", n, orig.remaining);