Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Boxes::setSize(unsigned int width, unsigned int height, unsigned int rows, unsigned int columns, unsigned int xsep, unsigned int ysep) {
- m_vertices.setPrimitiveType(sf::Lines);
- float w = (float)width / columns;
- float h = (float)height / rows;
- for(size_t i = 0; i < rows; i++) {
- for(size_t j = 0; j < columns; j++) {
- // Added counter clockwise
- Vector2f w(w * j + xsep, h * i + ysep);
- Vector2f x(w * j + xsep, h * (i + 1) - ysep);
- Vector2f y(w * (j + 1) - xsep, h * (i + 1) - ysep);
- Vector2f z(w * (j + 1) - xsep, h * i + ysep);
- m_vertices.append(w);
- m_vertices.append(x);
- m_vertices.append(x);
- m_vertices.append(y);
- m_vertices.append(y);
- m_vertices.append(z);
- m_vertices.append(z);
- m_vertices.append(w);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement