【问题标题】:Isometric tile placement等距瓷砖放置
【发布时间】: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


    【解决方案1】:
    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);
    

    由于我在纹理协调中犯了一个错误,所以一切都以错误的方式旋转。

    【讨论】:

      猜你喜欢
      • 2021-05-23
      • 1970-01-01
      • 2013-10-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-07-04
      • 1970-01-01
      相关资源
      最近更新 更多