X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Flevel.c;h=5f7f77b1f12f71a50065eede535eccd87e4b5e03;hb=32010751a69440b52780a4e570682f20b4ef70b2;hp=44c0bba4e9df5ff2ce0f31165a6f92c612a7ed50;hpb=0492cd9f104920e15a6ad3e7751bfe68b3bdaca7;p=vrlugburz diff --git a/src/level.c b/src/level.c index 44c0bba..5f7f77b 100644 --- a/src/level.c +++ b/src/level.c @@ -12,6 +12,9 @@ static int detect_cell_tile(struct level *lvl, int x, int y, int *rot); 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))) { @@ -22,6 +25,18 @@ int init_level(struct level *lvl, int xsz, int ysz) 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; ix = j; + cell->y = i; + cell++; + } + } return 0; } @@ -211,7 +226,7 @@ err: #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; @@ -245,49 +260,59 @@ static int detect_cell_tile(struct level *lvl, int x, int y, int *rot) 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;