hi, just as an aside to what i'm developing at the moment, I decided to try out using isometric perspective. Now to achieve this i made a minimal example:
sf::RenderWindow window;
window.create(sf::VideoMode(800, 800), "test");
window.setFramerateLimit(60);
sf::View view;
view.setCenter(100, 100);
view.setSize(800, 800);
resourceHolder res;
std::vector<std::vector<std::unique_ptr<sf::Sprite>>> sprites;
for (int i = 0; i < 10; i++)
{
std::vector<std::unique_ptr<sf::Sprite>> b;
sprites.push_back(std::move(b));
for (int j = 0; j < 10; j++)
{
auto a = std::unique_ptr<sf::Sprite>(new sf::Sprite);
a->setTexture(res.getTexture("graphics/isoGrass.png"));
sf::Vector2f vec(i * 32, j * 32);
sf::Vector2f vec2(0, 0);
vec2.x = vec.x - vec.y;
vec2.y = (vec.y + vec.x) / 2;
a->setPosition(vec2);
sprites[i].push_back(std::move(a));
}
}
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
{
window.close();
}
}
window.setView(view);
window.clear(sf::Color::Black);
for (int i = 0; i < sprites.size(); i++)
{
for (int j = 0; j < sprites[i].size(); j++)
{
window.draw(*sprites[i][j]);
}
}
window.display();
}
the code above gimes me
https://www.dropbox.com/s/rmp168f094v5ug1/isoGrid.jpg?dl=0 which is a diamond shaped grid as one would hope and expect. However, you'll notice that the 'cubes' are spaced out and so the grid is full of holes. Here is the png of the 'cube'
https://www.dropbox.com/s/z8v5y1vcdl48l1g/isoGrass.png?dl=0The only thing I can think is that there is something wrong with the dimensions of my 'cubes', all the tutorials i've seen simply use the formular in the above code to convert the cartesian coordinates into isometric ones, and this is working, hence the diamond shaped grid.
Any help would be greatly appreciated - thanks for your time.