Add BzTileID which refers to the tileset
This commit is contained in:
@@ -334,9 +334,10 @@ static void drawLayer(BzTileLayer *layer, BzTileset *tileset) {
|
||||
|
||||
for (i32 y = 0; y < layer->height; y++) {
|
||||
for (i32 x = 0; x < layer->width; x++) {
|
||||
BzTile tile = bzTileLayerGetTile(layer, x, y);
|
||||
if (tile - tileset->startID != -1) {
|
||||
Rectangle rec = bzTilesetGetTileRegion(tileset, tile);
|
||||
BzTile tile = bzTileLayerGetTile(layer, x, y);
|
||||
BzTileID tileID = bzTilesetGetTileID(tileset, tile);
|
||||
if (tileID != -1) {
|
||||
Rectangle rec = bzTilesetGetTileRegion(tileset, tileID);
|
||||
DrawTextureRec(tileset->tiles, rec, drawPos, WHITE);
|
||||
}
|
||||
drawPos.x += (float) tileset->tileWidth;
|
||||
@@ -382,7 +383,7 @@ BzTileObjectGroup *bzTileMapGetObjects(BzTileMap *map, i32 slotID) {
|
||||
BZ_ASSERT(slotID >= 0 && slotID < map->objectGroupCount);
|
||||
return &map->objectGroups[slotID];
|
||||
}
|
||||
static f32 abs(f32 x) {
|
||||
static f32 absf32(f32 x) {
|
||||
return x > 0 ? x : -x;
|
||||
}
|
||||
|
||||
@@ -399,7 +400,7 @@ f32 bzTileMapRayCast(BzTileMap *map, Vector2 from, Vector2 to, f32 maxDst, Vecto
|
||||
// sqrtf(1 + (dir.y / dir.x) * (dir.y / dir.x)),
|
||||
// sqrtf(1 + (dir.x / dir.y) * (dir.x / dir.y))
|
||||
//};
|
||||
Vector2 stepSize = {abs(1.0f / dir.x), abs(1.0f / dir.y)};
|
||||
Vector2 stepSize = {absf32(1.0f / dir.x), absf32(1.0f / dir.y)};
|
||||
|
||||
i32 cellX = (i32) from.x;
|
||||
i32 cellY = (i32) from.y;
|
||||
|
||||
Reference in New Issue
Block a user