int init_level(struct level *lvl, int xsz, int ysz)
{
+ int i, j;
+ struct cell *cell;
+
memset(lvl, 0, sizeof *lvl);
if(!(lvl->cells = calloc(xsz * ysz, sizeof *lvl->cells))) {
lvl->height = ysz;
lvl->cell_size = DEF_CELL_SIZE;
lvl->px = lvl->py = -1;
+
+ lvl->visdist = 4;
+
+ /* assign cell coordinates */
+ cell = lvl->cells;
+ for(i=0; i<ysz; i++) {
+ for(j=0; j<xsz; j++) {
+ cell->x = j;
+ cell->y = i;
+ cell++;
+ }
+ }
return 0;
}
#ifndef LEVEL_EDITOR
-static int get_cell_type(struct level *lvl, int x, int y)
+int get_cell_type(struct level *lvl, int x, int y)
{
if(x < 0 || x >= lvl->width || y < 0 || y >= lvl->height) {
return CELL_SOLID;
return TILE_OPEN;
case 0745:
- case 0744:
-
case 0645:
- case 0644:
- case 0740:
case 0741:
- case 0640:
case 0641:
return TILE_CORNER;
- case 0715:
- case 0711:
+ case 0744:
+ case 0644:
+ case 0740:
+ case 0640:
+ return TILE_OPENCORNER;
+
+ case 0715:
case 0315:
- case 0311:
- case 0710:
case 0714:
- case 0310:
case 0314:
*rot = 1;
return TILE_CORNER;
- case 0547:
- case 0447:
- case 0047:
+ case 0711:
+ case 0311:
+ case 0710:
+ case 0310:
+ *rot = 1;
+ return TILE_OPENCORNER;
+
+ case 0547:
case 0147:
- case 0446:
case 0546:
- case 0046:
case 0146:
*rot = 3;
return TILE_CORNER;
- case 0517:
- case 0117:
- case 0017:
+ case 0447:
+ case 0047:
+ case 0446:
+ case 0046:
+ *rot = 3;
+ return TILE_OPENCORNER;
+
+ case 0517:
case 0417:
- case 0113:
case 0513:
- case 0013:
case 0413:
*rot = 2;
return TILE_CORNER;
+ case 0117:
+ case 0017:
+ case 0113:
+ case 0013:
+ *rot = 2;
+ return TILE_OPENCORNER;
+
case 0507: /* N tee */
*rot = 3;
return TILE_TEE;