Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - natesdakota

Pages: [1]
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:

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.

Pages: [1]