【发布时间】:2021-10-22 20:32:01
【问题描述】:
我正在尝试制作带有顶点的等距平铺地图。我设法在没有顶点的情况下完成它。在我看来,它应该和不使用顶点一样简单,但我无法让它工作。已经进行了数十次尝试,但我错过了一些重要的事情。
const uint16_t tileMapSize = 16;
quad = &this->tilesDiamond[(x + y * tileMapSize) * 4]; // tilesDiamond is the vertexarray
const uint16_t blockWidth = 64, blockHeight = 64;
pos.x = (x-y) * blockWidth/2;
pos.y = (x + y) * blockWidth/2;
quad[0].position = sf::Vector2f(pos.x, pos.y);
quad[1].position = sf::Vector2f(pos.x+ blockWidth/2, pos.y+ blockWidth/2);
quad[2].position = sf::Vector2f(pos.x, pos.y + blockWidth);
quad[3].position = sf::Vector2f(pos.x - blockWidth/2, pos.y+ blockWidth/2);
这就是结果,它应该看起来像与瓷砖一起形成的菱形。 https://imgur.com/a/tYhvmZs.
【问题讨论】:
标签: c++ graphics sfml game-development isometric