This is the code:
//Render tiles
for (int i = 0; i < blockX.size(); i++) {
block.setPosition(float(blockX[i]), float(blockY[i]));
if (blockType[i] == "metal") {
//if block is metal tile
block.setTexture(metalBlockSingle);
if (doesBlockExist(blockX[i] + 20, blockY[i])) {
//if block is to right
if (doesBlockExist(blockX[i], blockY[i] + 20)) {
//if block is below
if (doesBlockExist(blockX[i] - 20, blockY[i])) {
//if block is to left
if (doesBlockExist(blockX[i], blockY[i] - 20)) {
//if block is above
block.setTexture(metalBlockCenter);
}
else {
block.setTexture(metalBlockBottomRightLeft);
}
}
else if (doesBlockExist(blockX[i], blockY[i] - 20)) {
//if block is above
block.setTexture(metalBlockTopBottomRight);
}
else {
//if block is neither above nor to left
block.setTexture(metalBlockBottomRight);
}
}
else if (doesBlockExist(blockX[i] - 20, blockY[i])) {
//if block is to left
if (doesBlockExist(blockX[i], blockY[i] - 20)) {
//if block is above
block.setTexture(metalBlockTopRightLeft);
}
else {
block.setTexture(metalBlockRightLeft);
}
}
else if (doesBlockExist(blockX[i], blockY[i] - 20)) {
//if block is above
block.setTexture(metalBlockTopRight);
}
else {
//if block is only right
block.setTexture(metalBlockRight);
}
}
else if (doesBlockExist(blockX[i], blockY[i] + 20)) {
//if block is below
if (doesBlockExist(blockX[i] - 20, blockY[i])) {
//if block is to left
if (doesBlockExist(blockX[i], blockY[i] - 20)) {
//if block is above
block.setTexture(metalBlockTopBottomLeft);
}
else {
//if block is not above
block.setTexture(metalBlockBottomLeft);
}
}
else {
//if block is not to left
if (doesBlockExist(blockX[i], blockY[i] - 20)) {
//if block is above
block.setTexture(metalBlockTopBottom);
}
else {
//if metal block is not above
block.setTexture(metalBlockBottom);
}
}
}
else if (doesBlockExist(blockX[i] - 20, blockY[i])) {
//if block is to left
if (doesBlockExist(blockX[i], blockY[i] - 20)) {
//if block is above
block.setTexture(metalBlockTopLeft);
}
else {
block.setTexture(metalBlockLeft);
}
}
else if (doesBlockExist(blockX[i], blockY[i] - 20)) {
//if block is above
block.setTexture(metalBlockTop);
}
}
window.draw(block);
}