Change collisionMap to boolean value
This commit is contained in:
@@ -37,28 +37,10 @@ bool canPlaceBuilding(BzTileMap *map, BuildingType type, BzTile tileX, BzTile ti
|
||||
if (tile == BUILDINGS_ROAD)
|
||||
return false;
|
||||
}
|
||||
BzTileShape shape = bzTileMapGetCollider(map, x, y);
|
||||
f32 posX = x * map->tileWidth;
|
||||
f32 posY = y * map->tileHeight;
|
||||
shape.x += posX;
|
||||
shape.y += posY;
|
||||
switch (shape.type) {
|
||||
case BZ_TILE_SHAPE_NONE:
|
||||
case BZ_TILE_SHAPE_POINT:
|
||||
break;
|
||||
case BZ_TILE_SHAPE_RECT: {
|
||||
Rectangle shapeRec = {shape.x, shape.y, shape.sizeX, shape.sizeY};
|
||||
if (CheckCollisionRecs(buildArea, shapeRec))
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
case BZ_TILE_SHAPE_ELLIPSE: {
|
||||
Vector2 pos = {shape.x, shape.y};
|
||||
f32 radius = (shape.sizeX + shape.sizeY) * 0.5f;
|
||||
if (CheckCollisionCircleRec(pos, radius, buildArea))
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
if (bzTileMapHasCollision(map, posX, posY)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -89,7 +71,7 @@ ecs_entity_t placeBuilding(BzTileMap *map, BuildingType type, BzTile tileX, BzTi
|
||||
bzTileLayerSetTile(buildingLayer, layerTile, x, y, 1, 1);
|
||||
buildingTile++;
|
||||
|
||||
bzTileMapUpdateColliders(map, x, y, 1, 1);
|
||||
bzTileMapUpdateCollisions(map, x, y, map->tileWidth, map->tileHeight);
|
||||
}
|
||||
buildingTile += buildingTileset->width - sizeX;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user