Tile list
This commit is contained in:
@ -152,7 +152,8 @@ void chunkListChunkLoad(chunklist_t *list, chunk_t *chunk,
|
||||
int32_t tx, ty, tz, i, count;
|
||||
tilesetdiv_t *div;
|
||||
tileref_t *tiles;
|
||||
tileref_t tile;
|
||||
tileref_t tileRef;
|
||||
tile_t *tile;
|
||||
|
||||
count = CHUNK_WIDTH * CHUNK_DEPTH * CHUNK_HEIGHT;
|
||||
tiles = calloc(count, sizeof(tileref_t));
|
||||
@ -163,10 +164,11 @@ void chunkListChunkLoad(chunklist_t *list, chunk_t *chunk,
|
||||
for(tx = 0; tx < CHUNK_WIDTH; tx++) {
|
||||
for(ty = 0; ty < CHUNK_HEIGHT; ty++) {
|
||||
for(tz = 0; tz < CHUNK_DEPTH; tz++) {
|
||||
tile = tiles[++i];
|
||||
if(tile == TILE_NULL) continue;
|
||||
div = &list->tilemap->tileset->divisions[tile];
|
||||
|
||||
tileRef = tiles[++i];
|
||||
if(tileRef == TILE_NULL) continue;
|
||||
div = list->tilemap->tileset->divisions + tileRef;
|
||||
tile = list->tilemap->tiles + tileRef;
|
||||
|
||||
spriteBatchQuad(chunk->batch, -1,
|
||||
tx, ty, tz, 1, 1,
|
||||
div->x0, div->y0, div->x1, div->y1
|
||||
|
@ -12,7 +12,7 @@ tilemap_t * tileMapCreate(tileset_t *tileset) {
|
||||
if(tilemap == NULL) return NULL;
|
||||
|
||||
tilemap->tileset = tileset;
|
||||
tilemap->tiles = malloc(sizeof(tile_t) * tileset->columns * tileset->rows);
|
||||
tilemap->tiles = calloc(tileset->columns * tileset->rows, sizeof(tile_t));
|
||||
|
||||
return tilemap;
|
||||
}
|
||||
|
Reference in New Issue
Block a user