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 - chaos407

Pages: [1]
1
I have looked in the FAQ and I understand all of the basic concepts listed there and most of the advanced concepts like operator overloading or templates. I understand all the SFML tutorials so far except for this one particular example.

In particular, why the math equations are written the way they are. For example, why is tu set to tileNumber % (m_tileset.getSize().x / tileSize.x);? Why is it (i+j*width)*4?

2
Graphics / Help understanding the Tile Map Example in SFML Tutorials 2.1
« on: October 25, 2014, 02:17:41 pm »
Is there a tutorial that is similar to this tile map example that can help make it easier to understand?

I am a beginner C++ programmer and I understand the basics of for loops as it is written here but I don't understand how each vertex is drawn to the vertex array m_verticies. Thanks.

http://www.sfml-dev.org/tutorials/2.1/graphics-vertex-array.php#example-tile-map

 
// get the current tile number
                int tileNumber = tiles[i + j * width];

                // find its position in the tileset texture
                int tu = tileNumber % (m_tileset.getSize().x / tileSize.x);
                int tv = tileNumber / (m_tileset.getSize().x / tileSize.x);

                // get a pointer to the current tile's quad
                sf::Vertex* quad = &m_vertices[(i + j * width) * 4];
            }
 

Pages: [1]
anything