1
SFML website / Errors in Vertex Arrays Tutorial for SFML 2.0
« on: May 02, 2013, 10:25:17 pm »
Hi,
I was reading through the tutorial module on vertex arrays, and I found a few code typos that might need to be fixed.
Please take a look at the tilemap example. When you are getting the position of the tile's texture from the texturemap, the tu variable is wrong. It currently reads:
A modulus should be used there instead like this:
Another couple of errors I found is when you define the quad's four corners. If you look at top left and bottom left corner the code is:
You're closing out those two parenthesis too early. The code should be something like:
Those corrections might be helpful for someone that's new to coding.
I was reading through the tutorial module on vertex arrays, and I found a few code typos that might need to be fixed.
Please take a look at the tilemap example. When you are getting the position of the tile's texture from the texturemap, the tu variable is wrong. It currently reads:
int tu = tileNumber / (m_tileset.getSize().x / tileSize.x);
A modulus should be used there instead like this:
int tu = tileNumber % (m_tileset.getSize().x / tileSize.x);
Another couple of errors I found is when you define the quad's four corners. If you look at top left and bottom left corner the code is:
quad[0].position = sf::Vector2f(i) * tileSize.x, j * tileSize.y);
quad[3].position = sf::Vector2f(i) * tileSize.x, (j + 1) * tileSize.y);
You're closing out those two parenthesis too early. The code should be something like:
quad[0].position = sf::Vector2f(i * tileSize.x, j * tileSize.y);
quad[3].position = sf::Vector2f(i * tileSize.x, (j + 1) * tileSize.y);
Those corrections might be helpful for someone that's new to coding.