1
General / Re: Changing a dungeon generating algorithm to use graphical tiles instead of text.
« on: March 24, 2017, 11:44:55 pm »
Hello again,
Is this what you are talking about with using vertex arrays instead of a sprite, Hapax?
Is this what you are talking about with using vertex arrays instead of a sprite, Hapax?
m_vertexArray = sf::VertexArray(sf::Quads, 4);
//Position setting
m_vertexArray[0].position = sf::Vector2f(posX, posY);
m_vertexArray[1].position = sf::Vector2f(posX + 10, posY);
m_vertexArray[2].position = sf::Vector2f(posX + 10, posY + 10);
m_vertexArray[3].position = sf::Vector2f(posX, posY + 10);
if (tileType == "floor")
{
m_vertexArray[0].texCoords = sf::Vector2f(56, 85);
m_vertexArray[1].texCoords = sf::Vector2f(64, 85);
m_vertexArray[2].texCoords = sf::Vector2f(64, 93);
m_vertexArray[3].texCoords = sf::Vector2f(56, 93);
}
else if (tileType == "wall")
{
m_vertexArray[0].texCoords = sf::Vector2f(47, 76);
m_vertexArray[1].texCoords = sf::Vector2f(55, 76);
m_vertexArray[2].texCoords = sf::Vector2f(55, 84);
m_vertexArray[3].texCoords = sf::Vector2f(47, 84);
}
else if (tileType == "closedDoor")
{
m_vertexArray[0].texCoords = sf::Vector2f(56, 85);
m_vertexArray[1].texCoords = sf::Vector2f(64, 85);
m_vertexArray[2].texCoords = sf::Vector2f(64, 93);
m_vertexArray[3].texCoords = sf::Vector2f(56, 93);
}
else if (tileType == "stairsUp")
{
m_vertexArray[0].texCoords = sf::Vector2f(137, 76);
m_vertexArray[1].texCoords = sf::Vector2f(145, 76);
m_vertexArray[2].texCoords = sf::Vector2f(145, 84);
m_vertexArray[3].texCoords = sf::Vector2f(137, 84);
}
else if (tileType == "stairsDown")
{
//m_sprite.setTextureRect(sf::IntRect(146, 76, 8, 8));
m_vertexArray[0].texCoords = sf::Vector2f(146, 76);
m_vertexArray[1].texCoords = sf::Vector2f(154, 76);
m_vertexArray[2].texCoords = sf::Vector2f(154, 84);
m_vertexArray[3].texCoords = sf::Vector2f(146, 84);
}
//Position setting
m_vertexArray[0].position = sf::Vector2f(posX, posY);
m_vertexArray[1].position = sf::Vector2f(posX + 10, posY);
m_vertexArray[2].position = sf::Vector2f(posX + 10, posY + 10);
m_vertexArray[3].position = sf::Vector2f(posX, posY + 10);
if (tileType == "floor")
{
m_vertexArray[0].texCoords = sf::Vector2f(56, 85);
m_vertexArray[1].texCoords = sf::Vector2f(64, 85);
m_vertexArray[2].texCoords = sf::Vector2f(64, 93);
m_vertexArray[3].texCoords = sf::Vector2f(56, 93);
}
else if (tileType == "wall")
{
m_vertexArray[0].texCoords = sf::Vector2f(47, 76);
m_vertexArray[1].texCoords = sf::Vector2f(55, 76);
m_vertexArray[2].texCoords = sf::Vector2f(55, 84);
m_vertexArray[3].texCoords = sf::Vector2f(47, 84);
}
else if (tileType == "closedDoor")
{
m_vertexArray[0].texCoords = sf::Vector2f(56, 85);
m_vertexArray[1].texCoords = sf::Vector2f(64, 85);
m_vertexArray[2].texCoords = sf::Vector2f(64, 93);
m_vertexArray[3].texCoords = sf::Vector2f(56, 93);
}
else if (tileType == "stairsUp")
{
m_vertexArray[0].texCoords = sf::Vector2f(137, 76);
m_vertexArray[1].texCoords = sf::Vector2f(145, 76);
m_vertexArray[2].texCoords = sf::Vector2f(145, 84);
m_vertexArray[3].texCoords = sf::Vector2f(137, 84);
}
else if (tileType == "stairsDown")
{
//m_sprite.setTextureRect(sf::IntRect(146, 76, 8, 8));
m_vertexArray[0].texCoords = sf::Vector2f(146, 76);
m_vertexArray[1].texCoords = sf::Vector2f(154, 76);
m_vertexArray[2].texCoords = sf::Vector2f(154, 84);
m_vertexArray[3].texCoords = sf::Vector2f(146, 84);
}