X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=vrlugburz;a=blobdiff_plain;f=src%2Flevel.c;h=5f7f77b1f12f71a50065eede535eccd87e4b5e03;hp=c17c03abc93292e604a5926dddd2a676a583b3f5;hb=32010751a69440b52780a4e570682f20b4ef70b2;hpb=594c18e3671a27624a867071b5bafd08148652b3 diff --git a/src/level.c b/src/level.c index c17c03a..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;