1
General / Re: Isometric algorithm is slightly off by a few pixels.
« on: September 19, 2016, 01:11:14 am »
I've found the issue. I don't think I was iterating through the tiles right for isometric. Instead of iterating 34/2 x for each tile, changing it to 36/2 worked. I also had to do - 2 for quad[1] and quad[2] to ensure the quads size was 34x18 as the graphics are.
Image result:
The fix:
Thanks to everyone who helped!
Image result:
(click to show/hide)
The fix:
quad[0].position = sf::Vector2f(offset_x + (j * (tileSize.x + 2) / 2) - (i * (tileSize.x + 2) / 2), offset_y + (i * tileSize.y / 2) + (j * tileSize.y / 2));
quad[1].position = sf::Vector2f(offset_x + (j * (tileSize.x + 2) / 2) - ((i+2) * (tileSize.x + 2) / 2) + 2, offset_y + (i * tileSize.y / 2) + (j * tileSize.y / 2));
quad[2].position = sf::Vector2f(offset_x + (j * (tileSize.x + 2) / 2) - ((i+2) * (tileSize.x + 2) / 2) + 2, offset_y + (i * tileSize.y / 2) + (((j+2) * tileSize.y) / 2));
quad[3].position = sf::Vector2f(offset_x + (j * (tileSize.x + 2) / 2) - (i * (tileSize.x + 2) / 2), offset_y + (i * tileSize.y / 2) + (((j+2) * tileSize.y) / 2));
quad[0].texCoords = sf::Vector2f(tu * tileSize.x, tv * tileSize.y);
quad[1].texCoords = sf::Vector2f((tu + 1) * tileSize.x, tv * tileSize.y);
quad[2].texCoords = sf::Vector2f((tu + 1) * tileSize.x, (tv + 1) * tileSize.y);
quad[3].texCoords = sf::Vector2f(tu * tileSize.x, (tv + 1) * tileSize.y);
quad[1].position = sf::Vector2f(offset_x + (j * (tileSize.x + 2) / 2) - ((i+2) * (tileSize.x + 2) / 2) + 2, offset_y + (i * tileSize.y / 2) + (j * tileSize.y / 2));
quad[2].position = sf::Vector2f(offset_x + (j * (tileSize.x + 2) / 2) - ((i+2) * (tileSize.x + 2) / 2) + 2, offset_y + (i * tileSize.y / 2) + (((j+2) * tileSize.y) / 2));
quad[3].position = sf::Vector2f(offset_x + (j * (tileSize.x + 2) / 2) - (i * (tileSize.x + 2) / 2), offset_y + (i * tileSize.y / 2) + (((j+2) * tileSize.y) / 2));
quad[0].texCoords = sf::Vector2f(tu * tileSize.x, tv * tileSize.y);
quad[1].texCoords = sf::Vector2f((tu + 1) * tileSize.x, tv * tileSize.y);
quad[2].texCoords = sf::Vector2f((tu + 1) * tileSize.x, (tv + 1) * tileSize.y);
quad[3].texCoords = sf::Vector2f(tu * tileSize.x, (tv + 1) * tileSize.y);
Thanks to everyone who helped!