Advertisement
Guest User

Untitled

a guest
Nov 26th, 2014
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. void Boxes::setSize(unsigned int width, unsigned int height, unsigned int rows, unsigned int columns, unsigned int xsep, unsigned int ysep) {
  2. m_vertices.setPrimitiveType(sf::Lines);
  3.  
  4. float w = (float)width / columns;
  5. float h = (float)height / rows;
  6.  
  7. for(size_t i = 0; i < rows; i++) {
  8. for(size_t j = 0; j < columns; j++) {
  9. // Added counter clockwise
  10. Vector2f w(w * j + xsep, h * i + ysep);
  11. Vector2f x(w * j + xsep, h * (i + 1) - ysep);
  12. Vector2f y(w * (j + 1) - xsep, h * (i + 1) - ysep);
  13. Vector2f z(w * (j + 1) - xsep, h * i + ysep);
  14.  
  15. m_vertices.append(w);
  16. m_vertices.append(x);
  17.  
  18. m_vertices.append(x);
  19. m_vertices.append(y);
  20.  
  21. m_vertices.append(y);
  22. m_vertices.append(z);
  23.  
  24. m_vertices.append(z);
  25. m_vertices.append(w);
  26. }
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement