Add input logic for building
This commit is contained in:
@@ -18,28 +18,22 @@ bool canPlaceBuilding(BzTileMap *map, BuildingType type, BzTile tileX, BzTile ti
|
||||
sizeX * map->tileWidth, sizeY * map->tileHeight};
|
||||
|
||||
// Need to check neighbour tiles
|
||||
tileX -= 1;
|
||||
tileY -= 1;
|
||||
sizeX += 2;
|
||||
sizeY += 2;
|
||||
//tileX -= 1;
|
||||
//tileY -= 1;
|
||||
//sizeX += 2;
|
||||
//sizeY += 2;
|
||||
|
||||
BzTileLayer *buildLayer = bzTileMapGetLayer(map, LAYER_BUILDINGS);
|
||||
BzTileset *tileset = bzTileLayerGetTileset(map, buildLayer);
|
||||
|
||||
for (i32 y = tileY; y < tileY + sizeY; y++) {
|
||||
for (i32 x = tileX; x < tileX + sizeX; x++) {
|
||||
if (x != tileX && x != tileX + sizeX - 1 &&
|
||||
y != tileY && y != tileY + sizeY - 1) {
|
||||
// Without padding
|
||||
BzTile tile = bzTileLayerGetTile(buildLayer, x, y);
|
||||
tile = bzTilesetGetTile(tileset, tile);
|
||||
tile = getTileBuilding(tile);
|
||||
if (tile == BUILDINGS_ROAD)
|
||||
return false;
|
||||
}
|
||||
f32 posX = x * map->tileWidth;
|
||||
f32 posY = y * map->tileHeight;
|
||||
if (bzTileMapHasCollision(map, posX, posY)) {
|
||||
BzTile tile = bzTileLayerGetTile(buildLayer, x, y);
|
||||
tile = bzTilesetGetTile(tileset, tile);
|
||||
tile = getTileBuilding(tile);
|
||||
if (tile == BUILDINGS_ROAD)
|
||||
return false;
|
||||
if (bzTileMapHasCollision(map, x, y)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user